{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/25639945","id":25639945,"diff_hunk":"@@ -0,0 +1,51 @@\n+package pidfile\n+\n+import (\n+\t\"fmt\"\n+\t\"io/ioutil\"\n+\t\"log\"\n+\t\"os\"\n+\t\"path/filepath\"\n+\t\"strconv\"\n+)\n+\n+type PidFile struct {\n+\tpath string\n+}\n+\n+func checkPidFileAlreadyExists(path string) error {\n+\tif pidString, err := ioutil.ReadFile(path); err == nil {\n+\t\tif pid, err := strconv.Atoi(string(pidString)); err == nil {\n+\t\t\tif _, err := os.Stat(filepath.Join(\"/proc\", string(pid))); err == nil {\n+\t\t\t\treturn fmt.Errorf(\"pid file found, ensure docker is not running or delete %s\", path)\n+\t\t\t}\n+\t\t}\n+\t}\n+\treturn nil\n+}\n+\n+func New(path string) (file *PidFile, err error) {\n+\tif err = checkPidFileAlreadyExists(path); err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\tcreatedFile, err := os.Create(path)","path":"pkg/pidfile/pidfile.go","position":32,"original_position":32,"commit_id":"cf4238a31cf235517601cc83d8d16e8972f68a96","original_commit_id":"db5d7b1d85d7b7d798cbbb516aeee706dbacdc48","user":{"login":"ahmetalpbalkan","id":159209,"avatar_url":"https://avatars.githubusercontent.com/u/159209?v=3","gravatar_id":"","url":"https://api.github.com/users/ahmetalpbalkan","html_url":"https://github.com/ahmetalpbalkan","followers_url":"https://api.github.com/users/ahmetalpbalkan/followers","following_url":"https://api.github.com/users/ahmetalpbalkan/following{/other_user}","gists_url":"https://api.github.com/users/ahmetalpbalkan/gists{/gist_id}","starred_url":"https://api.github.com/users/ahmetalpbalkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahmetalpbalkan/subscriptions","organizations_url":"https://api.github.com/users/ahmetalpbalkan/orgs","repos_url":"https://api.github.com/users/ahmetalpbalkan/repos","events_url":"https://api.github.com/users/ahmetalpbalkan/events{/privacy}","received_events_url":"https://api.github.com/users/ahmetalpbalkan/received_events","type":"User","site_admin":false},"body":"Just use []byte(fmt.Sprintf(\"%v\", val))\n\n\n\n\n—Alp\nhttp://alp.im\n\nOn Mon, Mar 2, 2015 at 1:22 PM, Rick Wieman <notifications@github.com>\nwrote:\n\n>> +\tif pidString, err := ioutil.ReadFile(path); err == nil {\n>> +\t\tif pid, err := strconv.Atoi(string(pidString)); err == nil {\n>> +\t\t\tif _, err := os.Stat(filepath.Join(\"/proc\", string(pid))); err == nil {\n>> +\t\t\t\treturn fmt.Errorf(\"pid file found, ensure docker is not running or delete %s\", path)\n>> +\t\t\t}\n>> +\t\t}\n>> +\t}\n>> +\treturn nil\n>> +}\n>> +\n>> +func New(path string) (file *PidFile, err error) {\n>> +\tif err = checkPidFileAlreadyExists(path); err != nil {\n>> +\t\treturn nil, err\n>> +\t}\n>> +\n>> +\tcreatedFile, err := os.Create(path)\n> That sounds nice indeed, and it would shorten the code a lot. However, when I tried this, I ran into a conversion from `int` to `[]byte`, for which I couldn't find a really nice solution.\n> Do you have a suggestion for that?\n> ---\n> Reply to this email directly or view it on GitHub:\n> https://github.com/docker/docker/pull/11018/files#r25639592","created_at":"2015-03-02T21:26:04Z","updated_at":"2015-03-02T21:26:04Z","html_url":"https://github.com/docker/docker/pull/11018#discussion_r25639945","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/11018","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/25639945"},"html":{"href":"https://github.com/docker/docker/pull/11018#discussion_r25639945"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/11018"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/11018","id":30016915,"html_url":"https://github.com/docker/docker/pull/11018","diff_url":"https://github.com/docker/docker/pull/11018.diff","patch_url":"https://github.com/docker/docker/pull/11018.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/11018","number":11018,"state":"open","locked":false,"title":"Moves pid file operations to /pkg/","user":{"login":"RickWieman","id":1265791,"avatar_url":"https://avatars.githubusercontent.com/u/1265791?v=3","gravatar_id":"","url":"https://api.github.com/users/RickWieman","html_url":"https://github.com/RickWieman","followers_url":"https://api.github.com/users/RickWieman/followers","following_url":"https://api.github.com/users/RickWieman/following{/other_user}","gists_url":"https://api.github.com/users/RickWieman/gists{/gist_id}","starred_url":"https://api.github.com/users/RickWieman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RickWieman/subscriptions","organizations_url":"https://api.github.com/users/RickWieman/orgs","repos_url":"https://api.github.com/users/RickWieman/repos","events_url":"https://api.github.com/users/RickWieman/events{/privacy}","received_events_url":"https://api.github.com/users/RickWieman/received_events","type":"User","site_admin":false},"body":"Fixes #10958 by moving `/utils/daemon` to `/pkg/pidfile`.\r\nI also added some test cases, and the daemon now uses the new `pidfile` package.","created_at":"2015-02-25T19:25:30Z","updated_at":"2015-03-02T21:26:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7b0c8b951aac647c73f925d7e6a13a7fd39cbac4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/11018/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/11018/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/11018/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/cf4238a31cf235517601cc83d8d16e8972f68a96","head":{"label":"delftswa2014:10958-pidfile","ref":"10958-pidfile","sha":"cf4238a31cf235517601cc83d8d16e8972f68a96","user":{"login":"delftswa2014","id":6429024,"avatar_url":"https://avatars.githubusercontent.com/u/6429024?v=3","gravatar_id":"","url":"https://api.github.com/users/delftswa2014","html_url":"https://github.com/delftswa2014","followers_url":"https://api.github.com/users/delftswa2014/followers","following_url":"https://api.github.com/users/delftswa2014/following{/other_user}","gists_url":"https://api.github.com/users/delftswa2014/gists{/gist_id}","starred_url":"https://api.github.com/users/delftswa2014/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delftswa2014/subscriptions","organizations_url":"https://api.github.com/users/delftswa2014/orgs","repos_url":"https://api.github.com/users/delftswa2014/repos","events_url":"https://api.github.com/users/delftswa2014/events{/privacy}","received_events_url":"https://api.github.com/users/delftswa2014/received_events","type":"Organization","site_admin":false},"repo":{"id":30772091,"name":"docker","full_name":"delftswa2014/docker","owner":{"login":"delftswa2014","id":6429024,"avatar_url":"https://avatars.githubusercontent.com/u/6429024?v=3","gravatar_id":"","url":"https://api.github.com/users/delftswa2014","html_url":"https://github.com/delftswa2014","followers_url":"https://api.github.com/users/delftswa2014/followers","following_url":"https://api.github.com/users/delftswa2014/following{/other_user}","gists_url":"https://api.github.com/users/delftswa2014/gists{/gist_id}","starred_url":"https://api.github.com/users/delftswa2014/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delftswa2014/subscriptions","organizations_url":"https://api.github.com/users/delftswa2014/orgs","repos_url":"https://api.github.com/users/delftswa2014/repos","events_url":"https://api.github.com/users/delftswa2014/events{/privacy}","received_events_url":"https://api.github.com/users/delftswa2014/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/delftswa2014/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/delftswa2014/docker","forks_url":"https://api.github.com/repos/delftswa2014/docker/forks","keys_url":"https://api.github.com/repos/delftswa2014/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/delftswa2014/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/delftswa2014/docker/teams","hooks_url":"https://api.github.com/repos/delftswa2014/docker/hooks","issue_events_url":"https://api.github.com/repos/delftswa2014/docker/issues/events{/number}","events_url":"https://api.github.com/repos/delftswa2014/docker/events","assignees_url":"https://api.github.com/repos/delftswa2014/docker/assignees{/user}","branches_url":"https://api.github.com/repos/delftswa2014/docker/branches{/branch}","tags_url":"https://api.github.com/repos/delftswa2014/docker/tags","blobs_url":"https://api.github.com/repos/delftswa2014/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/delftswa2014/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/delftswa2014/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/delftswa2014/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/delftswa2014/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/delftswa2014/docker/languages","stargazers_url":"https://api.github.com/repos/delftswa2014/docker/stargazers","contributors_url":"https://api.github.com/repos/delftswa2014/docker/contributors","subscribers_url":"https://api.github.com/repos/delftswa2014/docker/subscribers","subscription_url":"https://api.github.com/repos/delftswa2014/docker/subscription","commits_url":"https://api.github.com/repos/delftswa2014/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/delftswa2014/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/delftswa2014/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/delftswa2014/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/delftswa2014/docker/contents/{+path}","compare_url":"https://api.github.com/repos/delftswa2014/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/delftswa2014/docker/merges","archive_url":"https://api.github.com/repos/delftswa2014/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/delftswa2014/docker/downloads","issues_url":"https://api.github.com/repos/delftswa2014/docker/issues{/number}","pulls_url":"https://api.github.com/repos/delftswa2014/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/delftswa2014/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/delftswa2014/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/delftswa2014/docker/labels{/name}","releases_url":"https://api.github.com/repos/delftswa2014/docker/releases{/id}","created_at":"2015-02-13T19:26:12Z","updated_at":"2015-02-28T14:03:30Z","pushed_at":"2015-03-02T21:19:13Z","git_url":"git://github.com/delftswa2014/docker.git","ssh_url":"git@github.com:delftswa2014/docker.git","clone_url":"https://github.com/delftswa2014/docker.git","svn_url":"https://github.com/delftswa2014/docker","homepage":"http://www.docker.com","size":42249,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"f92213af882761a739fa0d8408e180e437b1a380","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":7691631,"name":"docker","full_name":"docker/docker","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/docker","description":"Docker - the open-source application container engine","fork":false,"url":"https://api.github.com/repos/docker/docker","forks_url":"https://api.github.com/repos/docker/docker/forks","keys_url":"https://api.github.com/repos/docker/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/docker/teams","hooks_url":"https://api.github.com/repos/docker/docker/hooks","issue_events_url":"https://api.github.com/repos/docker/docker/issues/events{/number}","events_url":"https://api.github.com/repos/docker/docker/events","assignees_url":"https://api.github.com/repos/docker/docker/assignees{/user}","branches_url":"https://api.github.com/repos/docker/docker/branches{/branch}","tags_url":"https://api.github.com/repos/docker/docker/tags","blobs_url":"https://api.github.com/repos/docker/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/docker/languages","stargazers_url":"https://api.github.com/repos/docker/docker/stargazers","contributors_url":"https://api.github.com/repos/docker/docker/contributors","subscribers_url":"https://api.github.com/repos/docker/docker/subscribers","subscription_url":"https://api.github.com/repos/docker/docker/subscription","commits_url":"https://api.github.com/repos/docker/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/docker/contents/{+path}","compare_url":"https://api.github.com/repos/docker/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/docker/merges","archive_url":"https://api.github.com/repos/docker/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/docker/downloads","issues_url":"https://api.github.com/repos/docker/docker/issues{/number}","pulls_url":"https://api.github.com/repos/docker/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/docker/labels{/name}","releases_url":"https://api.github.com/repos/docker/docker/releases{/id}","created_at":"2013-01-18T18:10:57Z","updated_at":"2015-03-02T21:24:13Z","pushed_at":"2015-03-02T20:41:22Z","git_url":"git://github.com/docker/docker.git","ssh_url":"git@github.com:docker/docker.git","clone_url":"https://github.com/docker/docker.git","svn_url":"https://github.com/docker/docker","homepage":"http://www.docker.com","size":143591,"stargazers_count":19509,"watchers_count":19509,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4042,"mirror_url":null,"open_issues_count":788,"forks":4042,"open_issues":788,"watchers":19509,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/11018"},"html":{"href":"https://github.com/docker/docker/pull/11018"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/11018"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/11018/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/11018/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/11018/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/cf4238a31cf235517601cc83d8d16e8972f68a96"}}}}