{"action":"created","issue":{"url":"https://api.github.com/repos/SPSCommerce/ansible-role-supervisor/issues/8","repository_url":"https://api.github.com/repos/SPSCommerce/ansible-role-supervisor","labels_url":"https://api.github.com/repos/SPSCommerce/ansible-role-supervisor/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/SPSCommerce/ansible-role-supervisor/issues/8/comments","events_url":"https://api.github.com/repos/SPSCommerce/ansible-role-supervisor/issues/8/events","html_url":"https://github.com/SPSCommerce/ansible-role-supervisor/pull/8","id":149567758,"number":8,"title":"Leverage sleep option of ansible service module to control restart","user":{"login":"eggilbert","id":6200216,"avatar_url":"https://avatars.githubusercontent.com/u/6200216?v=3","gravatar_id":"","url":"https://api.github.com/users/eggilbert","html_url":"https://github.com/eggilbert","followers_url":"https://api.github.com/users/eggilbert/followers","following_url":"https://api.github.com/users/eggilbert/following{/other_user}","gists_url":"https://api.github.com/users/eggilbert/gists{/gist_id}","starred_url":"https://api.github.com/users/eggilbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eggilbert/subscriptions","organizations_url":"https://api.github.com/users/eggilbert/orgs","repos_url":"https://api.github.com/users/eggilbert/repos","events_url":"https://api.github.com/users/eggilbert/events{/privacy}","received_events_url":"https://api.github.com/users/eggilbert/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-19T19:59:20Z","updated_at":"2016-04-19T19:59:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/SPSCommerce/ansible-role-supervisor/pulls/8","html_url":"https://github.com/SPSCommerce/ansible-role-supervisor/pull/8","diff_url":"https://github.com/SPSCommerce/ansible-role-supervisor/pull/8.diff","patch_url":"https://github.com/SPSCommerce/ansible-role-supervisor/pull/8.patch"},"body":"Lately we've been running into issues where supervisor fails to start on some of our deployments.\r\n```\r\nTASK: [restart supervisor] ****************************************************\r\nfailed: [172.17.0.8] => {\"failed\": true}\r\nmsg: Stopping supervisor: supervisord.\r\nStarting supervisor:\r\n\r\nFATAL: all hosts have already failed -- aborting\r\n```\r\n\r\nUltimately this appears to be a race condition between stopping the service, and then attempting to start it again before it actually completed stopping. It seems to send the stop signal and then immediately assume it's stopped.\r\n\r\n```\r\n2016-04-19 16:10:13,464 WARN received SIGTERM indicating exit request\r\n2016-04-19 16:10:13,465 INFO waiting for fulfillment-data-entry-bridge to die\r\n2016-04-19 16:10:13,873 INFO stopped: fulfillment-data-entry-bridge (exit status 143)\r\n```\r\n\r\nThis change here adds a delay between the stop and start phases of the service restart. Quote from [docs](http://docs.ansible.com/ansible/service_module.html):\r\n\r\n> If the service is being `restarted` then sleep this many seconds between the stop and start command. This helps to workaround badly behaving init scripts that exit immediately after signaling a process to stop.\r\n\r\nI've chosen the default sleep to be 5 seconds, which is what the supervisor init.d script would do, if ansible were set up to actually use that for the restart. Since the current behavior is broken in my opinion, I think this is better than making it backwards compatible and defaulting to nothing. But if people disagree I can change that, and just update my deployments to supply the new configuration option.\r\n\r\nRelated info:\r\nhttp://stackoverflow.com/questions/32738415/supervisor-fails-to-restart-half-of-the-time\r\nhttps://bugs.debian.org/cgi-bin/bugreport.cgi?bug=805920"},"comment":{"url":"https://api.github.com/repos/SPSCommerce/ansible-role-supervisor/issues/comments/212102245","html_url":"https://github.com/SPSCommerce/ansible-role-supervisor/pull/8#issuecomment-212102245","issue_url":"https://api.github.com/repos/SPSCommerce/ansible-role-supervisor/issues/8","id":212102245,"user":{"login":"eggilbert","id":6200216,"avatar_url":"https://avatars.githubusercontent.com/u/6200216?v=3","gravatar_id":"","url":"https://api.github.com/users/eggilbert","html_url":"https://github.com/eggilbert","followers_url":"https://api.github.com/users/eggilbert/followers","following_url":"https://api.github.com/users/eggilbert/following{/other_user}","gists_url":"https://api.github.com/users/eggilbert/gists{/gist_id}","starred_url":"https://api.github.com/users/eggilbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eggilbert/subscriptions","organizations_url":"https://api.github.com/users/eggilbert/orgs","repos_url":"https://api.github.com/users/eggilbert/repos","events_url":"https://api.github.com/users/eggilbert/events{/privacy}","received_events_url":"https://api.github.com/users/eggilbert/received_events","type":"User","site_admin":false},"created_at":"2016-04-19T19:59:31Z","updated_at":"2016-04-19T19:59:31Z","body":"@farrellit @danrue "}}