{"action":"created","comment":{"url":"https://api.github.com/repos/Tendrl/node-agent/pulls/comments/98941252","pull_request_review_id":19595780,"id":98941252,"diff_hunk":"@@ -0,0 +1,53 @@\n+import _socket\n+from _socket import error as _socket_error\n+import gevent.event\n+import gevent.greenlet\n+from gevent.server import StreamServer\n+from io import BlockingIOError\n+import os\n+from tendrl.commons.message import Message\n+from tendrl.node_agent.message.logger import Logger\n+\n+\n+RECEIVE_DATA_SIZE = 4096\n+PATH = \"/etc/tendrl/.node_agent_socket\"\n+\n+\n+class MessageHandler(gevent.greenlet.Greenlet):\n+    def __init__(self):\n+        super(MessageHandler, self).__init__()\n+        self.server = StreamServer(\n+            self.bind_unix_listener(),\n+            self.read_socket\n+        )\n+\n+    def read_socket(self, sock, address):\n+        try:\n+            data = sock.recv(RECEIVE_DATA_SIZE)\n+            message = Message.from_json(data)\n+            Logger(message)\n+        except (TypeError, ValueError, KeyError,\n+                _socket.error, _socket.timeout) as ex:\n+            raise ex\n+\n+    def _run(self):\n+        try:\n+            self.server.serve_forever()\n+        except (TypeError, BlockingIOError, _socket_error, ValueError) as ex:\n+            raise ex\n+\n+    def stop(self):\n+        self.sock.close()\n+        self.server.close()\n+\n+    def bind_unix_listener(self):\n+        try:\n+            if os.path.exists(PATH):\n+                os.remove(PATH)\n+            self.sock = _socket.socket(_socket.AF_UNIX, _socket.SOCK_STREAM)","path":"tendrl/node_agent/message/handler.py","position":47,"original_position":47,"commit_id":"07673a22871751c066529cd2f4f0b67f5cf6f432","original_commit_id":"93277c56a93edad06ebd556c64f488f3c8171fa4","user":{"login":"r0h4n","id":369941,"avatar_url":"https://avatars.githubusercontent.com/u/369941?v=3","gravatar_id":"","url":"https://api.github.com/users/r0h4n","html_url":"https://github.com/r0h4n","followers_url":"https://api.github.com/users/r0h4n/followers","following_url":"https://api.github.com/users/r0h4n/following{/other_user}","gists_url":"https://api.github.com/users/r0h4n/gists{/gist_id}","starred_url":"https://api.github.com/users/r0h4n/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r0h4n/subscriptions","organizations_url":"https://api.github.com/users/r0h4n/orgs","repos_url":"https://api.github.com/users/r0h4n/repos","events_url":"https://api.github.com/users/r0h4n/events{/privacy}","received_events_url":"https://api.github.com/users/r0h4n/received_events","type":"User","site_admin":false},"body":"http://www.gevent.org/gevent.socket.html","created_at":"2017-02-01T16:58:42Z","updated_at":"2017-02-01T16:59:08Z","html_url":"https://github.com/Tendrl/node-agent/pull/178#discussion_r98941252","pull_request_url":"https://api.github.com/repos/Tendrl/node-agent/pulls/178","_links":{"self":{"href":"https://api.github.com/repos/Tendrl/node-agent/pulls/comments/98941252"},"html":{"href":"https://github.com/Tendrl/node-agent/pull/178#discussion_r98941252"},"pull_request":{"href":"https://api.github.com/repos/Tendrl/node-agent/pulls/178"}}},"pull_request":{"url":"https://api.github.com/repos/Tendrl/node-agent/pulls/178","id":102941412,"html_url":"https://github.com/Tendrl/node-agent/pull/178","diff_url":"https://github.com/Tendrl/node-agent/pull/178.diff","patch_url":"https://github.com/Tendrl/node-agent/pull/178.patch","issue_url":"https://api.github.com/repos/Tendrl/node-agent/issues/178","number":178,"state":"open","locked":false,"title":"Logging implementation for tendrl","user":{"login":"GowthamShanmugam","id":15073590,"avatar_url":"https://avatars.githubusercontent.com/u/15073590?v=3","gravatar_id":"","url":"https://api.github.com/users/GowthamShanmugam","html_url":"https://github.com/GowthamShanmugam","followers_url":"https://api.github.com/users/GowthamShanmugam/followers","following_url":"https://api.github.com/users/GowthamShanmugam/following{/other_user}","gists_url":"https://api.github.com/users/GowthamShanmugam/gists{/gist_id}","starred_url":"https://api.github.com/users/GowthamShanmugam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GowthamShanmugam/subscriptions","organizations_url":"https://api.github.com/users/GowthamShanmugam/orgs","repos_url":"https://api.github.com/users/GowthamShanmugam/repos","events_url":"https://api.github.com/users/GowthamShanmugam/events{/privacy}","received_events_url":"https://api.github.com/users/GowthamShanmugam/received_events","type":"User","site_admin":false},"body":"tendrl-bug-id: Tendrl/specifications#28\r\ntendrl-spec: logging_implementation\r\n\r\n\r\nSigned-off-by: GowthamShanmugam <gshanmug@redhat.com>","created_at":"2017-01-24T15:32:16Z","updated_at":"2017-02-01T16:59:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"db58166238ab110ad4b8efb50178735c5786ca3f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Tendrl/node-agent/pulls/178/commits","review_comments_url":"https://api.github.com/repos/Tendrl/node-agent/pulls/178/comments","review_comment_url":"https://api.github.com/repos/Tendrl/node-agent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Tendrl/node-agent/issues/178/comments","statuses_url":"https://api.github.com/repos/Tendrl/node-agent/statuses/07673a22871751c066529cd2f4f0b67f5cf6f432","head":{"label":"GowthamShanmugam:logging","ref":"logging","sha":"07673a22871751c066529cd2f4f0b67f5cf6f432","user":{"login":"GowthamShanmugam","id":15073590,"avatar_url":"https://avatars.githubusercontent.com/u/15073590?v=3","gravatar_id":"","url":"https://api.github.com/users/GowthamShanmugam","html_url":"https://github.com/GowthamShanmugam","followers_url":"https://api.github.com/users/GowthamShanmugam/followers","following_url":"https://api.github.com/users/GowthamShanmugam/following{/other_user}","gists_url":"https://api.github.com/users/GowthamShanmugam/gists{/gist_id}","starred_url":"https://api.github.com/users/GowthamShanmugam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GowthamShanmugam/subscriptions","organizations_url":"https://api.github.com/users/GowthamShanmugam/orgs","repos_url":"https://api.github.com/users/GowthamShanmugam/repos","events_url":"https://api.github.com/users/GowthamShanmugam/events{/privacy}","received_events_url":"https://api.github.com/users/GowthamShanmugam/received_events","type":"User","site_admin":false},"repo":{"id":79902993,"name":"node-agent","full_name":"GowthamShanmugam/node-agent","owner":{"login":"GowthamShanmugam","id":15073590,"avatar_url":"https://avatars.githubusercontent.com/u/15073590?v=3","gravatar_id":"","url":"https://api.github.com/users/GowthamShanmugam","html_url":"https://github.com/GowthamShanmugam","followers_url":"https://api.github.com/users/GowthamShanmugam/followers","following_url":"https://api.github.com/users/GowthamShanmugam/following{/other_user}","gists_url":"https://api.github.com/users/GowthamShanmugam/gists{/gist_id}","starred_url":"https://api.github.com/users/GowthamShanmugam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GowthamShanmugam/subscriptions","organizations_url":"https://api.github.com/users/GowthamShanmugam/orgs","repos_url":"https://api.github.com/users/GowthamShanmugam/repos","events_url":"https://api.github.com/users/GowthamShanmugam/events{/privacy}","received_events_url":"https://api.github.com/users/GowthamShanmugam/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/GowthamShanmugam/node-agent","description":"A python agent local to every managed storage node in the sds cluster","fork":true,"url":"https://api.github.com/repos/GowthamShanmugam/node-agent","forks_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/forks","keys_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/teams","hooks_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/hooks","issue_events_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/issues/events{/number}","events_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/events","assignees_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/assignees{/user}","branches_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/branches{/branch}","tags_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/tags","blobs_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/languages","stargazers_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/stargazers","contributors_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/contributors","subscribers_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/subscribers","subscription_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/subscription","commits_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/contents/{+path}","compare_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/merges","archive_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/downloads","issues_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/issues{/number}","pulls_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/labels{/name}","releases_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/releases{/id}","deployments_url":"https://api.github.com/repos/GowthamShanmugam/node-agent/deployments","created_at":"2017-01-24T10:52:43Z","updated_at":"2017-01-24T10:52:45Z","pushed_at":"2017-02-01T16:32:44Z","git_url":"git://github.com/GowthamShanmugam/node-agent.git","ssh_url":"git@github.com:GowthamShanmugam/node-agent.git","clone_url":"https://github.com/GowthamShanmugam/node-agent.git","svn_url":"https://github.com/GowthamShanmugam/node-agent","homepage":null,"size":376,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Tendrl:master","ref":"master","sha":"6bfb841b90569346aa07eacc0072b05c8ce1712c","user":{"login":"Tendrl","id":19151627,"avatar_url":"https://avatars.githubusercontent.com/u/19151627?v=3","gravatar_id":"","url":"https://api.github.com/users/Tendrl","html_url":"https://github.com/Tendrl","followers_url":"https://api.github.com/users/Tendrl/followers","following_url":"https://api.github.com/users/Tendrl/following{/other_user}","gists_url":"https://api.github.com/users/Tendrl/gists{/gist_id}","starred_url":"https://api.github.com/users/Tendrl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tendrl/subscriptions","organizations_url":"https://api.github.com/users/Tendrl/orgs","repos_url":"https://api.github.com/users/Tendrl/repos","events_url":"https://api.github.com/users/Tendrl/events{/privacy}","received_events_url":"https://api.github.com/users/Tendrl/received_events","type":"Organization","site_admin":false},"repo":{"id":67720080,"name":"node-agent","full_name":"Tendrl/node-agent","owner":{"login":"Tendrl","id":19151627,"avatar_url":"https://avatars.githubusercontent.com/u/19151627?v=3","gravatar_id":"","url":"https://api.github.com/users/Tendrl","html_url":"https://github.com/Tendrl","followers_url":"https://api.github.com/users/Tendrl/followers","following_url":"https://api.github.com/users/Tendrl/following{/other_user}","gists_url":"https://api.github.com/users/Tendrl/gists{/gist_id}","starred_url":"https://api.github.com/users/Tendrl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tendrl/subscriptions","organizations_url":"https://api.github.com/users/Tendrl/orgs","repos_url":"https://api.github.com/users/Tendrl/repos","events_url":"https://api.github.com/users/Tendrl/events{/privacy}","received_events_url":"https://api.github.com/users/Tendrl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Tendrl/node-agent","description":"A python agent local to every managed storage node in the sds cluster","fork":false,"url":"https://api.github.com/repos/Tendrl/node-agent","forks_url":"https://api.github.com/repos/Tendrl/node-agent/forks","keys_url":"https://api.github.com/repos/Tendrl/node-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Tendrl/node-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Tendrl/node-agent/teams","hooks_url":"https://api.github.com/repos/Tendrl/node-agent/hooks","issue_events_url":"https://api.github.com/repos/Tendrl/node-agent/issues/events{/number}","events_url":"https://api.github.com/repos/Tendrl/node-agent/events","assignees_url":"https://api.github.com/repos/Tendrl/node-agent/assignees{/user}","branches_url":"https://api.github.com/repos/Tendrl/node-agent/branches{/branch}","tags_url":"https://api.github.com/repos/Tendrl/node-agent/tags","blobs_url":"https://api.github.com/repos/Tendrl/node-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Tendrl/node-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Tendrl/node-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/Tendrl/node-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Tendrl/node-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/Tendrl/node-agent/languages","stargazers_url":"https://api.github.com/repos/Tendrl/node-agent/stargazers","contributors_url":"https://api.github.com/repos/Tendrl/node-agent/contributors","subscribers_url":"https://api.github.com/repos/Tendrl/node-agent/subscribers","subscription_url":"https://api.github.com/repos/Tendrl/node-agent/subscription","commits_url":"https://api.github.com/repos/Tendrl/node-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/Tendrl/node-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/Tendrl/node-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/Tendrl/node-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/Tendrl/node-agent/contents/{+path}","compare_url":"https://api.github.com/repos/Tendrl/node-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Tendrl/node-agent/merges","archive_url":"https://api.github.com/repos/Tendrl/node-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Tendrl/node-agent/downloads","issues_url":"https://api.github.com/repos/Tendrl/node-agent/issues{/number}","pulls_url":"https://api.github.com/repos/Tendrl/node-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/Tendrl/node-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/Tendrl/node-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Tendrl/node-agent/labels{/name}","releases_url":"https://api.github.com/repos/Tendrl/node-agent/releases{/id}","deployments_url":"https://api.github.com/repos/Tendrl/node-agent/deployments","created_at":"2016-09-08T16:18:28Z","updated_at":"2017-01-29T14:17:32Z","pushed_at":"2017-02-01T16:32:45Z","git_url":"git://github.com/Tendrl/node-agent.git","ssh_url":"git@github.com:Tendrl/node-agent.git","clone_url":"https://github.com/Tendrl/node-agent.git","svn_url":"https://github.com/Tendrl/node-agent","homepage":null,"size":377,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":39,"forks":14,"open_issues":39,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Tendrl/node-agent/pulls/178"},"html":{"href":"https://github.com/Tendrl/node-agent/pull/178"},"issue":{"href":"https://api.github.com/repos/Tendrl/node-agent/issues/178"},"comments":{"href":"https://api.github.com/repos/Tendrl/node-agent/issues/178/comments"},"review_comments":{"href":"https://api.github.com/repos/Tendrl/node-agent/pulls/178/comments"},"review_comment":{"href":"https://api.github.com/repos/Tendrl/node-agent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Tendrl/node-agent/pulls/178/commits"},"statuses":{"href":"https://api.github.com/repos/Tendrl/node-agent/statuses/07673a22871751c066529cd2f4f0b67f5cf6f432"}}}}
{"actor":{"display_login":"r0h4n"}}