{"action":"created","issue":{"url":"https://api.github.com/repos/antirez/redis/issues/2368","labels_url":"https://api.github.com/repos/antirez/redis/issues/2368/labels{/name}","comments_url":"https://api.github.com/repos/antirez/redis/issues/2368/comments","events_url":"https://api.github.com/repos/antirez/redis/issues/2368/events","html_url":"https://github.com/antirez/redis/issues/2368","id":56821776,"number":2368,"title":"Server daemonizes itself before it is ready.","user":{"login":"phemmer","id":1826947,"avatar_url":"https://avatars.githubusercontent.com/u/1826947?v=3","gravatar_id":"","url":"https://api.github.com/users/phemmer","html_url":"https://github.com/phemmer","followers_url":"https://api.github.com/users/phemmer/followers","following_url":"https://api.github.com/users/phemmer/following{/other_user}","gists_url":"https://api.github.com/users/phemmer/gists{/gist_id}","starred_url":"https://api.github.com/users/phemmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phemmer/subscriptions","organizations_url":"https://api.github.com/users/phemmer/orgs","repos_url":"https://api.github.com/users/phemmer/repos","events_url":"https://api.github.com/users/phemmer/events{/privacy}","received_events_url":"https://api.github.com/users/phemmer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-06T15:00:32Z","updated_at":"2015-02-06T15:06:09Z","closed_at":null,"body":"When using the `--daemonize` option, the process backgrounds itself and causes the calling process to continue execution before redis is ready. At the point the caller resumes, neither the listening socket is ready, nor is the pid file created. This can cause the calling process to think that redis is dead.\r\n\r\nThe proper solution here is to fork off and create a new child process, but the parent process should block until signaled by the child that it should exit."},"comment":{"url":"https://api.github.com/repos/antirez/redis/issues/comments/73249907","html_url":"https://github.com/antirez/redis/issues/2368#issuecomment-73249907","issue_url":"https://api.github.com/repos/antirez/redis/issues/2368","id":73249907,"user":{"login":"mattsta","id":15594,"avatar_url":"https://avatars.githubusercontent.com/u/15594?v=3","gravatar_id":"","url":"https://api.github.com/users/mattsta","html_url":"https://github.com/mattsta","followers_url":"https://api.github.com/users/mattsta/followers","following_url":"https://api.github.com/users/mattsta/following{/other_user}","gists_url":"https://api.github.com/users/mattsta/gists{/gist_id}","starred_url":"https://api.github.com/users/mattsta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattsta/subscriptions","organizations_url":"https://api.github.com/users/mattsta/orgs","repos_url":"https://api.github.com/users/mattsta/repos","events_url":"https://api.github.com/users/mattsta/events{/privacy}","received_events_url":"https://api.github.com/users/mattsta/received_events","type":"User","site_admin":false},"created_at":"2015-02-06T15:06:09Z","updated_at":"2015-02-06T15:06:09Z","body":"Here's the Redis daemonize function (is it wrong?): https://github.com/antirez/redis/blob/2ac7b5a8b41bb71fce52c86f9ba420769663609e/src/redis.c#L3409-L3424\r\n\r\nAnd it gets called here: https://github.com/antirez/redis/blob/2ac7b5a8b41bb71fce52c86f9ba420769663609e/src/redis.c#L3805-L3846\r\n\r\n> At the point the caller resumes, neither the listening socket is ready, nor is the pid file created.\r\n\r\nRedis demonizes *before* it sets up networking and *before* dropping a PID, so you do get a daemon that can't handle requests immediately.\r\n\r\nRedis added [supervision support for systemd and upstart recently](https://github.com/antirez/redis/blob/2ac7b5a8b41bb71fce52c86f9ba420769663609e/src/redis.c#L3596-L3685), so some of those issues can be mitigated."}}