{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/26308145","id":26308145,"diff_hunk":"@@ -150,16 +154,42 @@ func mainDaemon() {\n \tjob.Setenv(\"TlsCert\", *flCert)\n \tjob.Setenv(\"TlsKey\", *flKey)\n \tjob.SetenvBool(\"BufferRequests\", true)\n-\terr := job.Run()\n+\n+\t// The serve API job never exits unless an error occurs\n+\t// We need to start it as a goroutine and wait on it so\n+\t// daemon doesn't exit\n+\tserveAPIWait := make(chan struct{})\n+\tgo func() {\n+\t\tdefer func() {\n+\t\t\t// if API job ever exits (on error or success)\n+\t\t\t// we want to shutdown cleanly and exit the daemon\n+\t\t\teng.Shutdown()\n+\t\t\tclose(serveAPIWait)\n+\t\t}()\n+\n+\t\tif err := job.Run(); err != nil {\n+\t\t\tlog.Errorf(\"Error from ServeAPI: %v\", err)\n+\t\t}\n+\t}()\n \n \t// Wait for the daemon startup goroutine to finish\n \t// This makes sure we can actually cleanly shutdown the daemon\n-\tlog.Infof(\"waiting for daemon to initialize\")\n-\t<-daemonWait\n-\teng.Shutdown()\n+\tlog.Debug(\"waiting for daemon to initialize\")\n+\terr := <-daemonInitWait\n \tif err != nil {\n-\t\t// log errors here so the log output looks more consistent\n-\t\tlog.Fatalf(\"shutting down daemon due to errors: %v\", err)\n+\t\tif !eng.IsShutdown() {","path":"docker/daemon.go","position":79,"original_position":79,"commit_id":"2918d217bb494c4a69cb0d82b90d94122bff0000","original_commit_id":"2918d217bb494c4a69cb0d82b90d94122bff0000","user":{"login":"cpuguy83","id":799078,"avatar_url":"https://avatars.githubusercontent.com/u/799078?v=3","gravatar_id":"","url":"https://api.github.com/users/cpuguy83","html_url":"https://github.com/cpuguy83","followers_url":"https://api.github.com/users/cpuguy83/followers","following_url":"https://api.github.com/users/cpuguy83/following{/other_user}","gists_url":"https://api.github.com/users/cpuguy83/gists{/gist_id}","starred_url":"https://api.github.com/users/cpuguy83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpuguy83/subscriptions","organizations_url":"https://api.github.com/users/cpuguy83/orgs","repos_url":"https://api.github.com/users/cpuguy83/repos","events_url":"https://api.github.com/users/cpuguy83/events{/privacy}","received_events_url":"https://api.github.com/users/cpuguy83/received_events","type":"User","site_admin":false},"body":"This is racey, might as well just shutdown, no?","created_at":"2015-03-12T14:53:54Z","updated_at":"2015-03-12T14:53:54Z","html_url":"https://github.com/docker/docker/pull/11320#discussion_r26308145","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/11320","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/26308145"},"html":{"href":"https://github.com/docker/docker/pull/11320#discussion_r26308145"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/11320"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/11320","id":30948492,"html_url":"https://github.com/docker/docker/pull/11320","diff_url":"https://github.com/docker/docker/pull/11320.diff","patch_url":"https://github.com/docker/docker/pull/11320.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/11320","number":11320,"state":"open","locked":false,"title":"Fix daemon shutdown on error after rework of daemon startup","user":{"login":"estesp","id":1397980,"avatar_url":"https://avatars.githubusercontent.com/u/1397980?v=3","gravatar_id":"","url":"https://api.github.com/users/estesp","html_url":"https://github.com/estesp","followers_url":"https://api.github.com/users/estesp/followers","following_url":"https://api.github.com/users/estesp/following{/other_user}","gists_url":"https://api.github.com/users/estesp/gists{/gist_id}","starred_url":"https://api.github.com/users/estesp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/estesp/subscriptions","organizations_url":"https://api.github.com/users/estesp/orgs","repos_url":"https://api.github.com/users/estesp/repos","events_url":"https://api.github.com/users/estesp/events{/privacy}","received_events_url":"https://api.github.com/users/estesp/received_events","type":"User","site_admin":false},"body":"Currently the daemon will not stop on error because the serve API job is\r\nblocking the channel wait for daemon init.  A better way is to run the\r\nblocking serve API job as a goroutine and make sure that error\r\nnotification gets back to the main daemon thread (using the already\r\nexisting channel) so that clean shutdown can occur on error.\r\n\r\nDocker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)","created_at":"2015-03-11T14:35:46Z","updated_at":"2015-03-12T14:53:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1fa1074af60d2a2fa42c06664dbcb342f277e1a5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/11320/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/11320/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/11320/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/2918d217bb494c4a69cb0d82b90d94122bff0000","head":{"label":"estesp:fix-daemon-startup","ref":"fix-daemon-startup","sha":"2918d217bb494c4a69cb0d82b90d94122bff0000","user":{"login":"estesp","id":1397980,"avatar_url":"https://avatars.githubusercontent.com/u/1397980?v=3","gravatar_id":"","url":"https://api.github.com/users/estesp","html_url":"https://github.com/estesp","followers_url":"https://api.github.com/users/estesp/followers","following_url":"https://api.github.com/users/estesp/following{/other_user}","gists_url":"https://api.github.com/users/estesp/gists{/gist_id}","starred_url":"https://api.github.com/users/estesp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/estesp/subscriptions","organizations_url":"https://api.github.com/users/estesp/orgs","repos_url":"https://api.github.com/users/estesp/repos","events_url":"https://api.github.com/users/estesp/events{/privacy}","received_events_url":"https://api.github.com/users/estesp/received_events","type":"User","site_admin":false},"repo":{"id":23801241,"name":"docker","full_name":"estesp/docker","owner":{"login":"estesp","id":1397980,"avatar_url":"https://avatars.githubusercontent.com/u/1397980?v=3","gravatar_id":"","url":"https://api.github.com/users/estesp","html_url":"https://github.com/estesp","followers_url":"https://api.github.com/users/estesp/followers","following_url":"https://api.github.com/users/estesp/following{/other_user}","gists_url":"https://api.github.com/users/estesp/gists{/gist_id}","starred_url":"https://api.github.com/users/estesp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/estesp/subscriptions","organizations_url":"https://api.github.com/users/estesp/orgs","repos_url":"https://api.github.com/users/estesp/repos","events_url":"https://api.github.com/users/estesp/events{/privacy}","received_events_url":"https://api.github.com/users/estesp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/estesp/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/estesp/docker","forks_url":"https://api.github.com/repos/estesp/docker/forks","keys_url":"https://api.github.com/repos/estesp/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/estesp/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/estesp/docker/teams","hooks_url":"https://api.github.com/repos/estesp/docker/hooks","issue_events_url":"https://api.github.com/repos/estesp/docker/issues/events{/number}","events_url":"https://api.github.com/repos/estesp/docker/events","assignees_url":"https://api.github.com/repos/estesp/docker/assignees{/user}","branches_url":"https://api.github.com/repos/estesp/docker/branches{/branch}","tags_url":"https://api.github.com/repos/estesp/docker/tags","blobs_url":"https://api.github.com/repos/estesp/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/estesp/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/estesp/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/estesp/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/estesp/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/estesp/docker/languages","stargazers_url":"https://api.github.com/repos/estesp/docker/stargazers","contributors_url":"https://api.github.com/repos/estesp/docker/contributors","subscribers_url":"https://api.github.com/repos/estesp/docker/subscribers","subscription_url":"https://api.github.com/repos/estesp/docker/subscription","commits_url":"https://api.github.com/repos/estesp/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/estesp/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/estesp/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/estesp/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/estesp/docker/contents/{+path}","compare_url":"https://api.github.com/repos/estesp/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/estesp/docker/merges","archive_url":"https://api.github.com/repos/estesp/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/estesp/docker/downloads","issues_url":"https://api.github.com/repos/estesp/docker/issues{/number}","pulls_url":"https://api.github.com/repos/estesp/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/estesp/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/estesp/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/estesp/docker/labels{/name}","releases_url":"https://api.github.com/repos/estesp/docker/releases{/id}","created_at":"2014-09-08T17:42:10Z","updated_at":"2015-03-11T17:07:54Z","pushed_at":"2015-03-12T13:48:32Z","git_url":"git://github.com/estesp/docker.git","ssh_url":"git@github.com:estesp/docker.git","clone_url":"https://github.com/estesp/docker.git","svn_url":"https://github.com/estesp/docker","homepage":"http://www.docker.com","size":45326,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"docker:master","ref":"master","sha":"d9c6787b4aa00db33b0f607dc67f1a83565f5269","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-12T14:30:56Z","pushed_at":"2015-03-12T14:30:56Z","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":153083,"stargazers_count":19771,"watchers_count":19771,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4116,"mirror_url":null,"open_issues_count":821,"forks":4116,"open_issues":821,"watchers":19771,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/11320"},"html":{"href":"https://github.com/docker/docker/pull/11320"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/11320"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/11320/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/11320/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/11320/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/2918d217bb494c4a69cb0d82b90d94122bff0000"}}}}