{"action":"created","issue":{"url":"https://api.github.com/repos/reverbrain/swarm/issues/37","labels_url":"https://api.github.com/repos/reverbrain/swarm/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/reverbrain/swarm/issues/37/comments","events_url":"https://api.github.com/repos/reverbrain/swarm/issues/37/events","html_url":"https://github.com/reverbrain/swarm/pull/37","id":66619267,"number":37,"title":"signal handling","user":{"login":"shindo","id":863752,"avatar_url":"https://avatars.githubusercontent.com/u/863752?v=3","gravatar_id":"","url":"https://api.github.com/users/shindo","html_url":"https://github.com/shindo","followers_url":"https://api.github.com/users/shindo/followers","following_url":"https://api.github.com/users/shindo/following{/other_user}","gists_url":"https://api.github.com/users/shindo/gists{/gist_id}","starred_url":"https://api.github.com/users/shindo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shindo/subscriptions","organizations_url":"https://api.github.com/users/shindo/orgs","repos_url":"https://api.github.com/users/shindo/repos","events_url":"https://api.github.com/users/shindo/events{/privacy}","received_events_url":"https://api.github.com/users/shindo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-04-06T14:43:15Z","updated_at":"2015-04-06T15:35:53Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/reverbrain/swarm/pulls/37","html_url":"https://github.com/reverbrain/swarm/pull/37","diff_url":"https://github.com/reverbrain/swarm/pull/37.diff","patch_url":"https://github.com/reverbrain/swarm/pull/37.patch"},"body":"This pull request solves the following problems:\r\n- buggy signal handling implementation\r\n- impossible to set custom set of signals for stop/reload actions\r\n- impossible to disable thevoid's signal handling\r\n\r\nAdded functions to register stop/reload signals:\r\n```(cpp)\r\nthevoid::register_stop_signal(int signal)\r\nthevoid::register_reload_signal(int signal)\r\n```\r\n\r\nIf one registers no signals for stop and reload, then no signals will be blocked and handled by thevoid.\r\n\r\nThese functions use `sigaction()` to register handler for specific signal process-wide.\r\n\r\nWhen registered stop signal will be catched all servers will be stopped (it works like \"stop the world\"). It's assumed that after receiving stop signal the whole process will terminate (thus, no server's restarting and so on) -- there's global \"received stop signal\" variable.\r\n\r\nWhen registered reload signal will be catched all servers will be asked to reload their configuration (with dummy reload() method, this functionality will be added sometime).\r\nReload signal handling is a little bit tricky, because we need to continue working after receiving such signals (and continue receiving reload signals) -- there's global \"received reload signal\" and global \"reload signal revision number\" variables.\r\nEach server somehow stores last handled reload signal's revision number, and if global \"reload signal revision number\" changes the server should handle global \"received reload signal\".\r\n\r\nAll this stuff (checking global variables, handling received signals) is performed within server's monitor io_service (thus, no separate thread) for each server.\r\n\r\nExample server shows how one can register different set of signals for stop/reload actions (it differs from default one)."},"comment":{"url":"https://api.github.com/repos/reverbrain/swarm/issues/comments/90111529","html_url":"https://github.com/reverbrain/swarm/pull/37#issuecomment-90111529","issue_url":"https://api.github.com/repos/reverbrain/swarm/issues/37","id":90111529,"user":{"login":"shindo","id":863752,"avatar_url":"https://avatars.githubusercontent.com/u/863752?v=3","gravatar_id":"","url":"https://api.github.com/users/shindo","html_url":"https://github.com/shindo","followers_url":"https://api.github.com/users/shindo/followers","following_url":"https://api.github.com/users/shindo/following{/other_user}","gists_url":"https://api.github.com/users/shindo/gists{/gist_id}","starred_url":"https://api.github.com/users/shindo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shindo/subscriptions","organizations_url":"https://api.github.com/users/shindo/orgs","repos_url":"https://api.github.com/users/shindo/repos","events_url":"https://api.github.com/users/shindo/events{/privacy}","received_events_url":"https://api.github.com/users/shindo/received_events","type":"User","site_admin":false},"created_at":"2015-04-06T15:35:53Z","updated_at":"2015-04-06T15:35:53Z","body":"Once again, all your servers have reload() method, just call it."}}