{"action":"created","comment":{"url":"https://api.github.com/repos/minio/minio/pulls/comments/73716821","id":73716821,"diff_hunk":"@@ -212,3 +280,83 @@ func longestWord(strings []string) int {\n \n \treturn maxLen\n }\n+\n+// Close initiates the graceful shutdown\n+func (m *MuxServer) Close() error {\n+\tm.mu.Lock()\n+\tif !m.closed {\n+\t\tm.Server.SetKeepAlivesEnabled(false)\n+\t\tm.closed = true\n+\t\tm.mu.Unlock()\n+\t\tif err := m.listener.Close(); err != nil {\n+\t\t\treturn err\n+\t\t}\n+\n+\t\t// force connections to close after timeout\n+\t\twait := make(chan struct{})\n+\t\tgo func() {\n+\t\t\tm.mu.Lock()\n+\t\t\tfor c, st := range m.conns {\n+\t\t\t\t// Force close any idle and new connections.\n+\t\t\t\tif st == http.StateIdle || st == http.StateNew {\n+\t\t\t\t\tc.Close()\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\tm.mu.Unlock()\n+\n+\t\t\t// Wait for all connections to be gracefully closed\n+\t\t\tm.wg.Wait()\n+\t\t\tclose(wait)\n+\t\t}()\n+\n+\t\tselect {\n+\t\tcase <-time.After(m.GracefulTimeout):\n+\t\t\treturn nil\n+\t\tcase <-wait:\n+\t\t\treturn nil\n+\t\t}\n+\t} else {","path":"server-mux.go","position":193,"original_position":193,"commit_id":"f6c9fbffde7c9d1e9b416555a450e2e16b7f8729","original_commit_id":"f6c9fbffde7c9d1e9b416555a450e2e16b7f8729","user":{"login":"harshavardhana","id":622699,"avatar_url":"https://avatars.githubusercontent.com/u/622699?v=3","gravatar_id":"","url":"https://api.github.com/users/harshavardhana","html_url":"https://github.com/harshavardhana","followers_url":"https://api.github.com/users/harshavardhana/followers","following_url":"https://api.github.com/users/harshavardhana/following{/other_user}","gists_url":"https://api.github.com/users/harshavardhana/gists{/gist_id}","starred_url":"https://api.github.com/users/harshavardhana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harshavardhana/subscriptions","organizations_url":"https://api.github.com/users/harshavardhana/orgs","repos_url":"https://api.github.com/users/harshavardhana/repos","events_url":"https://api.github.com/users/harshavardhana/events{/privacy}","received_events_url":"https://api.github.com/users/harshavardhana/received_events","type":"User","site_admin":false},"body":"I guess the logic would be reverted to avoid the 'if block' indentation. \r\n\r\n```\r\nif m.closed {\r\n   return errors.New(\"Server has been closed\")\r\n}\r\n...\r\n... the rest\r\n```","created_at":"2016-08-05T16:00:50Z","updated_at":"2016-08-05T16:00:50Z","html_url":"https://github.com/minio/minio/pull/2341#discussion_r73716821","pull_request_url":"https://api.github.com/repos/minio/minio/pulls/2341","_links":{"self":{"href":"https://api.github.com/repos/minio/minio/pulls/comments/73716821"},"html":{"href":"https://github.com/minio/minio/pull/2341#discussion_r73716821"},"pull_request":{"href":"https://api.github.com/repos/minio/minio/pulls/2341"}}},"pull_request":{"url":"https://api.github.com/repos/minio/minio/pulls/2341","id":79666604,"html_url":"https://github.com/minio/minio/pull/2341","diff_url":"https://github.com/minio/minio/pull/2341.diff","patch_url":"https://github.com/minio/minio/pull/2341.patch","issue_url":"https://api.github.com/repos/minio/minio/issues/2341","number":2341,"state":"open","locked":false,"title":"Graceful shutdown for ServerMux","user":{"login":"jesselucas","id":5431883,"avatar_url":"https://avatars.githubusercontent.com/u/5431883?v=3","gravatar_id":"","url":"https://api.github.com/users/jesselucas","html_url":"https://github.com/jesselucas","followers_url":"https://api.github.com/users/jesselucas/followers","following_url":"https://api.github.com/users/jesselucas/following{/other_user}","gists_url":"https://api.github.com/users/jesselucas/gists{/gist_id}","starred_url":"https://api.github.com/users/jesselucas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jesselucas/subscriptions","organizations_url":"https://api.github.com/users/jesselucas/orgs","repos_url":"https://api.github.com/users/jesselucas/repos","events_url":"https://api.github.com/users/jesselucas/events{/privacy}","received_events_url":"https://api.github.com/users/jesselucas/received_events","type":"User","site_admin":false},"body":"First attempt at adding graceful shutdown to ServerMux","created_at":"2016-08-02T02:17:53Z","updated_at":"2016-08-05T16:00:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"131d9b189c762eba68d218cc9ab0ba825379f51b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/minio/minio/pulls/2341/commits","review_comments_url":"https://api.github.com/repos/minio/minio/pulls/2341/comments","review_comment_url":"https://api.github.com/repos/minio/minio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/minio/minio/issues/2341/comments","statuses_url":"https://api.github.com/repos/minio/minio/statuses/f6c9fbffde7c9d1e9b416555a450e2e16b7f8729","head":{"label":"jesselucas:graceful","ref":"graceful","sha":"f6c9fbffde7c9d1e9b416555a450e2e16b7f8729","user":{"login":"jesselucas","id":5431883,"avatar_url":"https://avatars.githubusercontent.com/u/5431883?v=3","gravatar_id":"","url":"https://api.github.com/users/jesselucas","html_url":"https://github.com/jesselucas","followers_url":"https://api.github.com/users/jesselucas/followers","following_url":"https://api.github.com/users/jesselucas/following{/other_user}","gists_url":"https://api.github.com/users/jesselucas/gists{/gist_id}","starred_url":"https://api.github.com/users/jesselucas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jesselucas/subscriptions","organizations_url":"https://api.github.com/users/jesselucas/orgs","repos_url":"https://api.github.com/users/jesselucas/repos","events_url":"https://api.github.com/users/jesselucas/events{/privacy}","received_events_url":"https://api.github.com/users/jesselucas/received_events","type":"User","site_admin":false},"repo":{"id":64716113,"name":"minio","full_name":"jesselucas/minio","owner":{"login":"jesselucas","id":5431883,"avatar_url":"https://avatars.githubusercontent.com/u/5431883?v=3","gravatar_id":"","url":"https://api.github.com/users/jesselucas","html_url":"https://github.com/jesselucas","followers_url":"https://api.github.com/users/jesselucas/followers","following_url":"https://api.github.com/users/jesselucas/following{/other_user}","gists_url":"https://api.github.com/users/jesselucas/gists{/gist_id}","starred_url":"https://api.github.com/users/jesselucas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jesselucas/subscriptions","organizations_url":"https://api.github.com/users/jesselucas/orgs","repos_url":"https://api.github.com/users/jesselucas/repos","events_url":"https://api.github.com/users/jesselucas/events{/privacy}","received_events_url":"https://api.github.com/users/jesselucas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jesselucas/minio","description":"Minio is an object storage server compatible with Amazon S3 and licensed under Apache 2.0 License","fork":true,"url":"https://api.github.com/repos/jesselucas/minio","forks_url":"https://api.github.com/repos/jesselucas/minio/forks","keys_url":"https://api.github.com/repos/jesselucas/minio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jesselucas/minio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jesselucas/minio/teams","hooks_url":"https://api.github.com/repos/jesselucas/minio/hooks","issue_events_url":"https://api.github.com/repos/jesselucas/minio/issues/events{/number}","events_url":"https://api.github.com/repos/jesselucas/minio/events","assignees_url":"https://api.github.com/repos/jesselucas/minio/assignees{/user}","branches_url":"https://api.github.com/repos/jesselucas/minio/branches{/branch}","tags_url":"https://api.github.com/repos/jesselucas/minio/tags","blobs_url":"https://api.github.com/repos/jesselucas/minio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jesselucas/minio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jesselucas/minio/git/refs{/sha}","trees_url":"https://api.github.com/repos/jesselucas/minio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jesselucas/minio/statuses/{sha}","languages_url":"https://api.github.com/repos/jesselucas/minio/languages","stargazers_url":"https://api.github.com/repos/jesselucas/minio/stargazers","contributors_url":"https://api.github.com/repos/jesselucas/minio/contributors","subscribers_url":"https://api.github.com/repos/jesselucas/minio/subscribers","subscription_url":"https://api.github.com/repos/jesselucas/minio/subscription","commits_url":"https://api.github.com/repos/jesselucas/minio/commits{/sha}","git_commits_url":"https://api.github.com/repos/jesselucas/minio/git/commits{/sha}","comments_url":"https://api.github.com/repos/jesselucas/minio/comments{/number}","issue_comment_url":"https://api.github.com/repos/jesselucas/minio/issues/comments{/number}","contents_url":"https://api.github.com/repos/jesselucas/minio/contents/{+path}","compare_url":"https://api.github.com/repos/jesselucas/minio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jesselucas/minio/merges","archive_url":"https://api.github.com/repos/jesselucas/minio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jesselucas/minio/downloads","issues_url":"https://api.github.com/repos/jesselucas/minio/issues{/number}","pulls_url":"https://api.github.com/repos/jesselucas/minio/pulls{/number}","milestones_url":"https://api.github.com/repos/jesselucas/minio/milestones{/number}","notifications_url":"https://api.github.com/repos/jesselucas/minio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jesselucas/minio/labels{/name}","releases_url":"https://api.github.com/repos/jesselucas/minio/releases{/id}","deployments_url":"https://api.github.com/repos/jesselucas/minio/deployments","created_at":"2016-08-02T02:08:54Z","updated_at":"2016-08-02T02:08:55Z","pushed_at":"2016-08-05T15:09:48Z","git_url":"git://github.com/jesselucas/minio.git","ssh_url":"git@github.com:jesselucas/minio.git","clone_url":"https://github.com/jesselucas/minio.git","svn_url":"https://github.com/jesselucas/minio","homepage":"https://minio.io/downloads/","size":15033,"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":"minio:master","ref":"master","sha":"d63ce9d60d9a864398165ffe4089786be4827f4c","user":{"login":"minio","id":695951,"avatar_url":"https://avatars.githubusercontent.com/u/695951?v=3","gravatar_id":"","url":"https://api.github.com/users/minio","html_url":"https://github.com/minio","followers_url":"https://api.github.com/users/minio/followers","following_url":"https://api.github.com/users/minio/following{/other_user}","gists_url":"https://api.github.com/users/minio/gists{/gist_id}","starred_url":"https://api.github.com/users/minio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minio/subscriptions","organizations_url":"https://api.github.com/users/minio/orgs","repos_url":"https://api.github.com/users/minio/repos","events_url":"https://api.github.com/users/minio/events{/privacy}","received_events_url":"https://api.github.com/users/minio/received_events","type":"Organization","site_admin":false},"repo":{"id":29261473,"name":"minio","full_name":"minio/minio","owner":{"login":"minio","id":695951,"avatar_url":"https://avatars.githubusercontent.com/u/695951?v=3","gravatar_id":"","url":"https://api.github.com/users/minio","html_url":"https://github.com/minio","followers_url":"https://api.github.com/users/minio/followers","following_url":"https://api.github.com/users/minio/following{/other_user}","gists_url":"https://api.github.com/users/minio/gists{/gist_id}","starred_url":"https://api.github.com/users/minio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minio/subscriptions","organizations_url":"https://api.github.com/users/minio/orgs","repos_url":"https://api.github.com/users/minio/repos","events_url":"https://api.github.com/users/minio/events{/privacy}","received_events_url":"https://api.github.com/users/minio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/minio/minio","description":"Minio is an object storage server compatible with Amazon S3 and licensed under Apache 2.0 License","fork":false,"url":"https://api.github.com/repos/minio/minio","forks_url":"https://api.github.com/repos/minio/minio/forks","keys_url":"https://api.github.com/repos/minio/minio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/minio/minio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/minio/minio/teams","hooks_url":"https://api.github.com/repos/minio/minio/hooks","issue_events_url":"https://api.github.com/repos/minio/minio/issues/events{/number}","events_url":"https://api.github.com/repos/minio/minio/events","assignees_url":"https://api.github.com/repos/minio/minio/assignees{/user}","branches_url":"https://api.github.com/repos/minio/minio/branches{/branch}","tags_url":"https://api.github.com/repos/minio/minio/tags","blobs_url":"https://api.github.com/repos/minio/minio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/minio/minio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/minio/minio/git/refs{/sha}","trees_url":"https://api.github.com/repos/minio/minio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/minio/minio/statuses/{sha}","languages_url":"https://api.github.com/repos/minio/minio/languages","stargazers_url":"https://api.github.com/repos/minio/minio/stargazers","contributors_url":"https://api.github.com/repos/minio/minio/contributors","subscribers_url":"https://api.github.com/repos/minio/minio/subscribers","subscription_url":"https://api.github.com/repos/minio/minio/subscription","commits_url":"https://api.github.com/repos/minio/minio/commits{/sha}","git_commits_url":"https://api.github.com/repos/minio/minio/git/commits{/sha}","comments_url":"https://api.github.com/repos/minio/minio/comments{/number}","issue_comment_url":"https://api.github.com/repos/minio/minio/issues/comments{/number}","contents_url":"https://api.github.com/repos/minio/minio/contents/{+path}","compare_url":"https://api.github.com/repos/minio/minio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/minio/minio/merges","archive_url":"https://api.github.com/repos/minio/minio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/minio/minio/downloads","issues_url":"https://api.github.com/repos/minio/minio/issues{/number}","pulls_url":"https://api.github.com/repos/minio/minio/pulls{/number}","milestones_url":"https://api.github.com/repos/minio/minio/milestones{/number}","notifications_url":"https://api.github.com/repos/minio/minio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/minio/minio/labels{/name}","releases_url":"https://api.github.com/repos/minio/minio/releases{/id}","deployments_url":"https://api.github.com/repos/minio/minio/deployments","created_at":"2015-01-14T19:23:58Z","updated_at":"2016-08-05T15:50:36Z","pushed_at":"2016-08-05T15:09:48Z","git_url":"git://github.com/minio/minio.git","ssh_url":"git@github.com:minio/minio.git","clone_url":"https://github.com/minio/minio.git","svn_url":"https://github.com/minio/minio","homepage":"https://minio.io/downloads/","size":16576,"stargazers_count":1989,"watchers_count":1989,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":166,"mirror_url":null,"open_issues_count":45,"forks":166,"open_issues":45,"watchers":1989,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/minio/minio/pulls/2341"},"html":{"href":"https://github.com/minio/minio/pull/2341"},"issue":{"href":"https://api.github.com/repos/minio/minio/issues/2341"},"comments":{"href":"https://api.github.com/repos/minio/minio/issues/2341/comments"},"review_comments":{"href":"https://api.github.com/repos/minio/minio/pulls/2341/comments"},"review_comment":{"href":"https://api.github.com/repos/minio/minio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/minio/minio/pulls/2341/commits"},"statuses":{"href":"https://api.github.com/repos/minio/minio/statuses/f6c9fbffde7c9d1e9b416555a450e2e16b7f8729"}}}}
{"actor":{"display_login":"harshavardhana"}}