{"action":"created","comment":{"url":"https://api.github.com/repos/syncthing/syncthing/pulls/comments/31609683","id":31609683,"diff_hunk":"@@ -210,15 +212,63 @@ func (s *apiSvc) Serve() {\n \t\tReadTimeout: 10 * time.Second,\n \t}\n \n+\ts.fss = newFolderSummarySvc(s.model)\n+\tdefer s.fss.Stop()\n \ts.fss.ServeBackground()\n \n+\tl.Infoln(\"API listening on\", s.listener.Addr())\n \terr := srv.Serve(s.listener)\n-\tl.Warnln(\"API:\", err)\n+\n+\t// The return could be due to an intentional close. Wait for the stop\n+\t// signal before returning. IF there is no stop signal within a second, we\n+\t// assume it was unintentional and log the error before retrying.\n+\tselect {\n+\tcase <-s.stop:\n+\tcase <-time.After(time.Second):\n+\t\tl.Warnln(\"API:\", err)\n+\t}\n }\n \n func (s *apiSvc) Stop() {\n+\tclose(s.stop)\n \ts.listener.Close()\n-\ts.fss.Stop()\n+}\n+\n+func (s *apiSvc) String() string {\n+\treturn fmt.Sprintf(\"apiSvc@%p\", s)\n+}\n+\n+func (s *apiSvc) VerifyConfiguration(from, to config.Configuration) error {\n+\treturn nil\n+}\n+\n+func (s *apiSvc) CommitConfiguration(from, to config.Configuration) bool {\n+\tif to.GUI == from.GUI {\n+\t\treturn true\n+\t}\n+\n+\t// Order here is important. We must close the listener to stop Serve(). We\n+\t// must create a new listener before Serve() starts again. We can't create\n+\t// a new listener on the same port before the previous listener is closed.\n+\t// To assist in this little dance the Serve() method will wait for a\n+\t// signal on the stop channel after the listener has closed.\n+\n+\ts.listener.Close()\n+\n+\tvar err error\n+\ts.listener, err = s.getListener(to.GUI)\n+\tif err != nil {\n+\t\t// Ideally this should be a verification error, but we check it by\n+\t\t// creating a new listener which requires shutting down the previous\n+\t\t// one first, which is too destructive for the VerifyConfiguration\n+\t\t// method.\n+\t\treturn false\n+\t}\n+\ts.cfg = to.GUI\n+\n+\tclose(s.stop)","path":"cmd/syncthing/gui.go","position":107,"original_position":107,"commit_id":"85d3b9bd872d6cd2b88cad803db42fb5a7f95ed2","original_commit_id":"85d3b9bd872d6cd2b88cad803db42fb5a7f95ed2","user":{"login":"calmh","id":125426,"avatar_url":"https://avatars.githubusercontent.com/u/125426?v=3","gravatar_id":"","url":"https://api.github.com/users/calmh","html_url":"https://github.com/calmh","followers_url":"https://api.github.com/users/calmh/followers","following_url":"https://api.github.com/users/calmh/following{/other_user}","gists_url":"https://api.github.com/users/calmh/gists{/gist_id}","starred_url":"https://api.github.com/users/calmh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calmh/subscriptions","organizations_url":"https://api.github.com/users/calmh/orgs","repos_url":"https://api.github.com/users/calmh/repos","events_url":"https://api.github.com/users/calmh/events{/privacy}","received_events_url":"https://api.github.com/users/calmh/received_events","type":"User","site_admin":false},"body":"Yeah. suture will rerun the `Serve` method unless the service manager itself is stopped (in which case it'll run `Stop` instead)","created_at":"2015-06-03T10:12:46Z","updated_at":"2015-06-03T10:12:46Z","html_url":"https://github.com/syncthing/syncthing/pull/1810#discussion_r31609683","pull_request_url":"https://api.github.com/repos/syncthing/syncthing/pulls/1810","_links":{"self":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/comments/31609683"},"html":{"href":"https://github.com/syncthing/syncthing/pull/1810#discussion_r31609683"},"pull_request":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/1810"}}},"pull_request":{"url":"https://api.github.com/repos/syncthing/syncthing/pulls/1810","id":35444242,"html_url":"https://github.com/syncthing/syncthing/pull/1810","diff_url":"https://github.com/syncthing/syncthing/pull/1810.diff","patch_url":"https://github.com/syncthing/syncthing/pull/1810.patch","issue_url":"https://api.github.com/repos/syncthing/syncthing/issues/1810","number":1810,"state":"open","locked":false,"title":"(wip) Configuration commit thingy","user":{"login":"calmh","id":125426,"avatar_url":"https://avatars.githubusercontent.com/u/125426?v=3","gravatar_id":"","url":"https://api.github.com/users/calmh","html_url":"https://github.com/calmh","followers_url":"https://api.github.com/users/calmh/followers","following_url":"https://api.github.com/users/calmh/following{/other_user}","gists_url":"https://api.github.com/users/calmh/gists{/gist_id}","starred_url":"https://api.github.com/users/calmh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calmh/subscriptions","organizations_url":"https://api.github.com/users/calmh/orgs","repos_url":"https://api.github.com/users/calmh/repos","events_url":"https://api.github.com/users/calmh/events{/privacy}","received_events_url":"https://api.github.com/users/calmh/received_events","type":"User","site_admin":false},"body":"So this is the thing that might lead up to non-restart config changes. This doesn't get there, but lays the groundwork. It's not complete yet, but some comments would be nice. Please check the description for the `Committer` interface at the top of `config/wrapper.go` to see if that makes sense going forward; the rest is basically just plumbing to implement the interface in a couple of places, and the API does attempt restartless config changes just to show it works, kinda...","created_at":"2015-05-14T17:49:18Z","updated_at":"2015-06-03T10:12:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"803d1142d6d9920f5411ea54dd117727f6d48c27","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/syncthing/syncthing/pulls/1810/commits","review_comments_url":"https://api.github.com/repos/syncthing/syncthing/pulls/1810/comments","review_comment_url":"https://api.github.com/repos/syncthing/syncthing/pulls/comments{/number}","comments_url":"https://api.github.com/repos/syncthing/syncthing/issues/1810/comments","statuses_url":"https://api.github.com/repos/syncthing/syncthing/statuses/85d3b9bd872d6cd2b88cad803db42fb5a7f95ed2","head":{"label":"calmh:cfg-commit","ref":"cfg-commit","sha":"85d3b9bd872d6cd2b88cad803db42fb5a7f95ed2","user":{"login":"calmh","id":125426,"avatar_url":"https://avatars.githubusercontent.com/u/125426?v=3","gravatar_id":"","url":"https://api.github.com/users/calmh","html_url":"https://github.com/calmh","followers_url":"https://api.github.com/users/calmh/followers","following_url":"https://api.github.com/users/calmh/following{/other_user}","gists_url":"https://api.github.com/users/calmh/gists{/gist_id}","starred_url":"https://api.github.com/users/calmh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calmh/subscriptions","organizations_url":"https://api.github.com/users/calmh/orgs","repos_url":"https://api.github.com/users/calmh/repos","events_url":"https://api.github.com/users/calmh/events{/privacy}","received_events_url":"https://api.github.com/users/calmh/received_events","type":"User","site_admin":false},"repo":{"id":29292392,"name":"syncthing","full_name":"calmh/syncthing","owner":{"login":"calmh","id":125426,"avatar_url":"https://avatars.githubusercontent.com/u/125426?v=3","gravatar_id":"","url":"https://api.github.com/users/calmh","html_url":"https://github.com/calmh","followers_url":"https://api.github.com/users/calmh/followers","following_url":"https://api.github.com/users/calmh/following{/other_user}","gists_url":"https://api.github.com/users/calmh/gists{/gist_id}","starred_url":"https://api.github.com/users/calmh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calmh/subscriptions","organizations_url":"https://api.github.com/users/calmh/orgs","repos_url":"https://api.github.com/users/calmh/repos","events_url":"https://api.github.com/users/calmh/events{/privacy}","received_events_url":"https://api.github.com/users/calmh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/calmh/syncthing","description":"This is my personal fork of the repo, not the official one! It may be outdated, broken, rebased upon and generally screwed around with. Don't watch it, star it, or fork from it! :)","fork":true,"url":"https://api.github.com/repos/calmh/syncthing","forks_url":"https://api.github.com/repos/calmh/syncthing/forks","keys_url":"https://api.github.com/repos/calmh/syncthing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/calmh/syncthing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/calmh/syncthing/teams","hooks_url":"https://api.github.com/repos/calmh/syncthing/hooks","issue_events_url":"https://api.github.com/repos/calmh/syncthing/issues/events{/number}","events_url":"https://api.github.com/repos/calmh/syncthing/events","assignees_url":"https://api.github.com/repos/calmh/syncthing/assignees{/user}","branches_url":"https://api.github.com/repos/calmh/syncthing/branches{/branch}","tags_url":"https://api.github.com/repos/calmh/syncthing/tags","blobs_url":"https://api.github.com/repos/calmh/syncthing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/calmh/syncthing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/calmh/syncthing/git/refs{/sha}","trees_url":"https://api.github.com/repos/calmh/syncthing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/calmh/syncthing/statuses/{sha}","languages_url":"https://api.github.com/repos/calmh/syncthing/languages","stargazers_url":"https://api.github.com/repos/calmh/syncthing/stargazers","contributors_url":"https://api.github.com/repos/calmh/syncthing/contributors","subscribers_url":"https://api.github.com/repos/calmh/syncthing/subscribers","subscription_url":"https://api.github.com/repos/calmh/syncthing/subscription","commits_url":"https://api.github.com/repos/calmh/syncthing/commits{/sha}","git_commits_url":"https://api.github.com/repos/calmh/syncthing/git/commits{/sha}","comments_url":"https://api.github.com/repos/calmh/syncthing/comments{/number}","issue_comment_url":"https://api.github.com/repos/calmh/syncthing/issues/comments{/number}","contents_url":"https://api.github.com/repos/calmh/syncthing/contents/{+path}","compare_url":"https://api.github.com/repos/calmh/syncthing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/calmh/syncthing/merges","archive_url":"https://api.github.com/repos/calmh/syncthing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/calmh/syncthing/downloads","issues_url":"https://api.github.com/repos/calmh/syncthing/issues{/number}","pulls_url":"https://api.github.com/repos/calmh/syncthing/pulls{/number}","milestones_url":"https://api.github.com/repos/calmh/syncthing/milestones{/number}","notifications_url":"https://api.github.com/repos/calmh/syncthing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/calmh/syncthing/labels{/name}","releases_url":"https://api.github.com/repos/calmh/syncthing/releases{/id}","created_at":"2015-01-15T10:31:42Z","updated_at":"2015-05-12T17:26:25Z","pushed_at":"2015-06-03T07:48:19Z","git_url":"git://github.com/calmh/syncthing.git","ssh_url":"git@github.com:calmh/syncthing.git","clone_url":"https://github.com/calmh/syncthing.git","svn_url":"https://github.com/calmh/syncthing","homepage":"https://github.com/syncthing/syncthing","size":49130,"stargazers_count":9,"watchers_count":9,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":0,"forks":4,"open_issues":0,"watchers":9,"default_branch":"master"}},"base":{"label":"syncthing:master","ref":"master","sha":"25b25b5434145d733841d78683d56021d5116a87","user":{"login":"syncthing","id":7628018,"avatar_url":"https://avatars.githubusercontent.com/u/7628018?v=3","gravatar_id":"","url":"https://api.github.com/users/syncthing","html_url":"https://github.com/syncthing","followers_url":"https://api.github.com/users/syncthing/followers","following_url":"https://api.github.com/users/syncthing/following{/other_user}","gists_url":"https://api.github.com/users/syncthing/gists{/gist_id}","starred_url":"https://api.github.com/users/syncthing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syncthing/subscriptions","organizations_url":"https://api.github.com/users/syncthing/orgs","repos_url":"https://api.github.com/users/syncthing/repos","events_url":"https://api.github.com/users/syncthing/events{/privacy}","received_events_url":"https://api.github.com/users/syncthing/received_events","type":"Organization","site_admin":false},"repo":{"id":14712850,"name":"syncthing","full_name":"syncthing/syncthing","owner":{"login":"syncthing","id":7628018,"avatar_url":"https://avatars.githubusercontent.com/u/7628018?v=3","gravatar_id":"","url":"https://api.github.com/users/syncthing","html_url":"https://github.com/syncthing","followers_url":"https://api.github.com/users/syncthing/followers","following_url":"https://api.github.com/users/syncthing/following{/other_user}","gists_url":"https://api.github.com/users/syncthing/gists{/gist_id}","starred_url":"https://api.github.com/users/syncthing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syncthing/subscriptions","organizations_url":"https://api.github.com/users/syncthing/orgs","repos_url":"https://api.github.com/users/syncthing/repos","events_url":"https://api.github.com/users/syncthing/events{/privacy}","received_events_url":"https://api.github.com/users/syncthing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/syncthing/syncthing","description":"Open Source Continuous File Synchronization","fork":false,"url":"https://api.github.com/repos/syncthing/syncthing","forks_url":"https://api.github.com/repos/syncthing/syncthing/forks","keys_url":"https://api.github.com/repos/syncthing/syncthing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/syncthing/syncthing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/syncthing/syncthing/teams","hooks_url":"https://api.github.com/repos/syncthing/syncthing/hooks","issue_events_url":"https://api.github.com/repos/syncthing/syncthing/issues/events{/number}","events_url":"https://api.github.com/repos/syncthing/syncthing/events","assignees_url":"https://api.github.com/repos/syncthing/syncthing/assignees{/user}","branches_url":"https://api.github.com/repos/syncthing/syncthing/branches{/branch}","tags_url":"https://api.github.com/repos/syncthing/syncthing/tags","blobs_url":"https://api.github.com/repos/syncthing/syncthing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/syncthing/syncthing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/syncthing/syncthing/git/refs{/sha}","trees_url":"https://api.github.com/repos/syncthing/syncthing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/syncthing/syncthing/statuses/{sha}","languages_url":"https://api.github.com/repos/syncthing/syncthing/languages","stargazers_url":"https://api.github.com/repos/syncthing/syncthing/stargazers","contributors_url":"https://api.github.com/repos/syncthing/syncthing/contributors","subscribers_url":"https://api.github.com/repos/syncthing/syncthing/subscribers","subscription_url":"https://api.github.com/repos/syncthing/syncthing/subscription","commits_url":"https://api.github.com/repos/syncthing/syncthing/commits{/sha}","git_commits_url":"https://api.github.com/repos/syncthing/syncthing/git/commits{/sha}","comments_url":"https://api.github.com/repos/syncthing/syncthing/comments{/number}","issue_comment_url":"https://api.github.com/repos/syncthing/syncthing/issues/comments{/number}","contents_url":"https://api.github.com/repos/syncthing/syncthing/contents/{+path}","compare_url":"https://api.github.com/repos/syncthing/syncthing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/syncthing/syncthing/merges","archive_url":"https://api.github.com/repos/syncthing/syncthing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/syncthing/syncthing/downloads","issues_url":"https://api.github.com/repos/syncthing/syncthing/issues{/number}","pulls_url":"https://api.github.com/repos/syncthing/syncthing/pulls{/number}","milestones_url":"https://api.github.com/repos/syncthing/syncthing/milestones{/number}","notifications_url":"https://api.github.com/repos/syncthing/syncthing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/syncthing/syncthing/labels{/name}","releases_url":"https://api.github.com/repos/syncthing/syncthing/releases{/id}","created_at":"2013-11-26T09:48:21Z","updated_at":"2015-06-03T07:02:03Z","pushed_at":"2015-06-03T07:48:20Z","git_url":"git://github.com/syncthing/syncthing.git","ssh_url":"git@github.com:syncthing/syncthing.git","clone_url":"https://github.com/syncthing/syncthing.git","svn_url":"https://github.com/syncthing/syncthing","homepage":"http://forum.syncthing.net/","size":66594,"stargazers_count":8673,"watchers_count":8673,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":604,"mirror_url":null,"open_issues_count":146,"forks":604,"open_issues":146,"watchers":8673,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/1810"},"html":{"href":"https://github.com/syncthing/syncthing/pull/1810"},"issue":{"href":"https://api.github.com/repos/syncthing/syncthing/issues/1810"},"comments":{"href":"https://api.github.com/repos/syncthing/syncthing/issues/1810/comments"},"review_comments":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/1810/comments"},"review_comment":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/1810/commits"},"statuses":{"href":"https://api.github.com/repos/syncthing/syncthing/statuses/85d3b9bd872d6cd2b88cad803db42fb5a7f95ed2"}}}}