{"action":"closed","number":1135,"pull_request":{"url":"https://api.github.com/repos/resque/resque/pulls/1135","id":8917448,"html_url":"https://github.com/resque/resque/pull/1135","diff_url":"https://github.com/resque/resque/pull/1135.diff","patch_url":"https://github.com/resque/resque/pull/1135.patch","issue_url":"https://api.github.com/repos/resque/resque/issues/1135","number":1135,"state":"closed","locked":false,"title":"Add hook when process is put into the background","user":{"login":"broglep-koubachi","id":1199504,"avatar_url":"https://avatars.githubusercontent.com/u/1199504?v=3","gravatar_id":"","url":"https://api.github.com/users/broglep-koubachi","html_url":"https://github.com/broglep-koubachi","followers_url":"https://api.github.com/users/broglep-koubachi/followers","following_url":"https://api.github.com/users/broglep-koubachi/following{/other_user}","gists_url":"https://api.github.com/users/broglep-koubachi/gists{/gist_id}","starred_url":"https://api.github.com/users/broglep-koubachi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broglep-koubachi/subscriptions","organizations_url":"https://api.github.com/users/broglep-koubachi/orgs","repos_url":"https://api.github.com/users/broglep-koubachi/repos","events_url":"https://api.github.com/users/broglep-koubachi/events{/privacy}","received_events_url":"https://api.github.com/users/broglep-koubachi/received_events","type":"User","site_admin":false},"body":"When resque workers are put into the background / daemonized with BACKGROUND=yes, it might be that you get \"Redis::InheritedError: Tried to use a connection from a child process without reconnecting.\" error in cases where the redis connection was opened before the worker is put into the background (e.g. due to loading the rails environment)\r\n\r\nWe tried to fix this issues by reconnecting to redis in `before_first_hook`, but the exception we experienced are raised before the `before_first_fork` is run, namely in `prune_dead_workers`.\r\n\r\nIt is to be discussed whether a better fix would be to run the `before_first_fork` somewhere earlier, e.g. at the beginning of `startup`, instead of adding a new `after_background` hook.\r\n\r\nDue to unclear backwards compatibility implications we decided to add a new hook right after `Process.deamon`.\r\nThis will also make sure that reconnecting to redis is performed as early as possible so that potential new code won't connect to redis before `before_first_fork` would be run.\r\n","created_at":"2013-10-08T13:42:56Z","updated_at":"2016-01-08T14:28:13Z","closed_at":"2016-01-08T14:28:13Z","merged_at":null,"merge_commit_sha":"f1ac0dad2037ac40715a2920f0bd2893de0e64e3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/resque/resque/pulls/1135/commits","review_comments_url":"https://api.github.com/repos/resque/resque/pulls/1135/comments","review_comment_url":"https://api.github.com/repos/resque/resque/pulls/comments{/number}","comments_url":"https://api.github.com/repos/resque/resque/issues/1135/comments","statuses_url":"https://api.github.com/repos/resque/resque/statuses/4b30fc274e58d73f7c1126de555972c973f16f6a","head":{"label":"broglep-koubachi:1-x-stable","ref":"1-x-stable","sha":"4b30fc274e58d73f7c1126de555972c973f16f6a","user":{"login":"broglep-koubachi","id":1199504,"avatar_url":"https://avatars.githubusercontent.com/u/1199504?v=3","gravatar_id":"","url":"https://api.github.com/users/broglep-koubachi","html_url":"https://github.com/broglep-koubachi","followers_url":"https://api.github.com/users/broglep-koubachi/followers","following_url":"https://api.github.com/users/broglep-koubachi/following{/other_user}","gists_url":"https://api.github.com/users/broglep-koubachi/gists{/gist_id}","starred_url":"https://api.github.com/users/broglep-koubachi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broglep-koubachi/subscriptions","organizations_url":"https://api.github.com/users/broglep-koubachi/orgs","repos_url":"https://api.github.com/users/broglep-koubachi/repos","events_url":"https://api.github.com/users/broglep-koubachi/events{/privacy}","received_events_url":"https://api.github.com/users/broglep-koubachi/received_events","type":"User","site_admin":false},"repo":{"id":4545553,"name":"resque","full_name":"broglep-koubachi/resque","owner":{"login":"broglep-koubachi","id":1199504,"avatar_url":"https://avatars.githubusercontent.com/u/1199504?v=3","gravatar_id":"","url":"https://api.github.com/users/broglep-koubachi","html_url":"https://github.com/broglep-koubachi","followers_url":"https://api.github.com/users/broglep-koubachi/followers","following_url":"https://api.github.com/users/broglep-koubachi/following{/other_user}","gists_url":"https://api.github.com/users/broglep-koubachi/gists{/gist_id}","starred_url":"https://api.github.com/users/broglep-koubachi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broglep-koubachi/subscriptions","organizations_url":"https://api.github.com/users/broglep-koubachi/orgs","repos_url":"https://api.github.com/users/broglep-koubachi/repos","events_url":"https://api.github.com/users/broglep-koubachi/events{/privacy}","received_events_url":"https://api.github.com/users/broglep-koubachi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/broglep-koubachi/resque","description":"Resque is a Redis-backed Ruby library for creating background jobs, placing them on multiple queues, and processing them later.","fork":true,"url":"https://api.github.com/repos/broglep-koubachi/resque","forks_url":"https://api.github.com/repos/broglep-koubachi/resque/forks","keys_url":"https://api.github.com/repos/broglep-koubachi/resque/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broglep-koubachi/resque/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broglep-koubachi/resque/teams","hooks_url":"https://api.github.com/repos/broglep-koubachi/resque/hooks","issue_events_url":"https://api.github.com/repos/broglep-koubachi/resque/issues/events{/number}","events_url":"https://api.github.com/repos/broglep-koubachi/resque/events","assignees_url":"https://api.github.com/repos/broglep-koubachi/resque/assignees{/user}","branches_url":"https://api.github.com/repos/broglep-koubachi/resque/branches{/branch}","tags_url":"https://api.github.com/repos/broglep-koubachi/resque/tags","blobs_url":"https://api.github.com/repos/broglep-koubachi/resque/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broglep-koubachi/resque/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broglep-koubachi/resque/git/refs{/sha}","trees_url":"https://api.github.com/repos/broglep-koubachi/resque/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broglep-koubachi/resque/statuses/{sha}","languages_url":"https://api.github.com/repos/broglep-koubachi/resque/languages","stargazers_url":"https://api.github.com/repos/broglep-koubachi/resque/stargazers","contributors_url":"https://api.github.com/repos/broglep-koubachi/resque/contributors","subscribers_url":"https://api.github.com/repos/broglep-koubachi/resque/subscribers","subscription_url":"https://api.github.com/repos/broglep-koubachi/resque/subscription","commits_url":"https://api.github.com/repos/broglep-koubachi/resque/commits{/sha}","git_commits_url":"https://api.github.com/repos/broglep-koubachi/resque/git/commits{/sha}","comments_url":"https://api.github.com/repos/broglep-koubachi/resque/comments{/number}","issue_comment_url":"https://api.github.com/repos/broglep-koubachi/resque/issues/comments{/number}","contents_url":"https://api.github.com/repos/broglep-koubachi/resque/contents/{+path}","compare_url":"https://api.github.com/repos/broglep-koubachi/resque/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broglep-koubachi/resque/merges","archive_url":"https://api.github.com/repos/broglep-koubachi/resque/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broglep-koubachi/resque/downloads","issues_url":"https://api.github.com/repos/broglep-koubachi/resque/issues{/number}","pulls_url":"https://api.github.com/repos/broglep-koubachi/resque/pulls{/number}","milestones_url":"https://api.github.com/repos/broglep-koubachi/resque/milestones{/number}","notifications_url":"https://api.github.com/repos/broglep-koubachi/resque/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broglep-koubachi/resque/labels{/name}","releases_url":"https://api.github.com/repos/broglep-koubachi/resque/releases{/id}","created_at":"2012-06-04T09:44:32Z","updated_at":"2013-10-28T07:06:57Z","pushed_at":"2013-10-08T12:53:00Z","git_url":"git://github.com/broglep-koubachi/resque.git","ssh_url":"git@github.com:broglep-koubachi/resque.git","clone_url":"https://github.com/broglep-koubachi/resque.git","svn_url":"https://github.com/broglep-koubachi/resque","homepage":"http://github.com/blog/542-introducing-resque","size":2391,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"resque:1-x-stable","ref":"1-x-stable","sha":"5379faa08db53233d7a1bbc4f1e01104be7d7851","user":{"login":"resque","id":3876747,"avatar_url":"https://avatars.githubusercontent.com/u/3876747?v=3","gravatar_id":"","url":"https://api.github.com/users/resque","html_url":"https://github.com/resque","followers_url":"https://api.github.com/users/resque/followers","following_url":"https://api.github.com/users/resque/following{/other_user}","gists_url":"https://api.github.com/users/resque/gists{/gist_id}","starred_url":"https://api.github.com/users/resque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resque/subscriptions","organizations_url":"https://api.github.com/users/resque/orgs","repos_url":"https://api.github.com/users/resque/repos","events_url":"https://api.github.com/users/resque/events{/privacy}","received_events_url":"https://api.github.com/users/resque/received_events","type":"Organization","site_admin":false},"repo":{"id":275604,"name":"resque","full_name":"resque/resque","owner":{"login":"resque","id":3876747,"avatar_url":"https://avatars.githubusercontent.com/u/3876747?v=3","gravatar_id":"","url":"https://api.github.com/users/resque","html_url":"https://github.com/resque","followers_url":"https://api.github.com/users/resque/followers","following_url":"https://api.github.com/users/resque/following{/other_user}","gists_url":"https://api.github.com/users/resque/gists{/gist_id}","starred_url":"https://api.github.com/users/resque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resque/subscriptions","organizations_url":"https://api.github.com/users/resque/orgs","repos_url":"https://api.github.com/users/resque/repos","events_url":"https://api.github.com/users/resque/events{/privacy}","received_events_url":"https://api.github.com/users/resque/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/resque/resque","description":"Resque is a Redis-backed Ruby library for creating background jobs, placing them on multiple queues, and processing them later.","fork":false,"url":"https://api.github.com/repos/resque/resque","forks_url":"https://api.github.com/repos/resque/resque/forks","keys_url":"https://api.github.com/repos/resque/resque/keys{/key_id}","collaborators_url":"https://api.github.com/repos/resque/resque/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/resque/resque/teams","hooks_url":"https://api.github.com/repos/resque/resque/hooks","issue_events_url":"https://api.github.com/repos/resque/resque/issues/events{/number}","events_url":"https://api.github.com/repos/resque/resque/events","assignees_url":"https://api.github.com/repos/resque/resque/assignees{/user}","branches_url":"https://api.github.com/repos/resque/resque/branches{/branch}","tags_url":"https://api.github.com/repos/resque/resque/tags","blobs_url":"https://api.github.com/repos/resque/resque/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/resque/resque/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/resque/resque/git/refs{/sha}","trees_url":"https://api.github.com/repos/resque/resque/git/trees{/sha}","statuses_url":"https://api.github.com/repos/resque/resque/statuses/{sha}","languages_url":"https://api.github.com/repos/resque/resque/languages","stargazers_url":"https://api.github.com/repos/resque/resque/stargazers","contributors_url":"https://api.github.com/repos/resque/resque/contributors","subscribers_url":"https://api.github.com/repos/resque/resque/subscribers","subscription_url":"https://api.github.com/repos/resque/resque/subscription","commits_url":"https://api.github.com/repos/resque/resque/commits{/sha}","git_commits_url":"https://api.github.com/repos/resque/resque/git/commits{/sha}","comments_url":"https://api.github.com/repos/resque/resque/comments{/number}","issue_comment_url":"https://api.github.com/repos/resque/resque/issues/comments{/number}","contents_url":"https://api.github.com/repos/resque/resque/contents/{+path}","compare_url":"https://api.github.com/repos/resque/resque/compare/{base}...{head}","merges_url":"https://api.github.com/repos/resque/resque/merges","archive_url":"https://api.github.com/repos/resque/resque/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/resque/resque/downloads","issues_url":"https://api.github.com/repos/resque/resque/issues{/number}","pulls_url":"https://api.github.com/repos/resque/resque/pulls{/number}","milestones_url":"https://api.github.com/repos/resque/resque/milestones{/number}","notifications_url":"https://api.github.com/repos/resque/resque/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/resque/resque/labels{/name}","releases_url":"https://api.github.com/repos/resque/resque/releases{/id}","created_at":"2009-08-12T00:27:35Z","updated_at":"2016-01-08T09:19:58Z","pushed_at":"2016-01-05T01:56:47Z","git_url":"git://github.com/resque/resque.git","ssh_url":"git@github.com:resque/resque.git","clone_url":"https://github.com/resque/resque.git","svn_url":"https://github.com/resque/resque","homepage":"http://github.com/blog/542-introducing-resque","size":5994,"stargazers_count":7040,"watchers_count":7040,"language":"Ruby","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":1303,"mirror_url":null,"open_issues_count":116,"forks":1303,"open_issues":116,"watchers":7040,"default_branch":"1-x-stable"}},"_links":{"self":{"href":"https://api.github.com/repos/resque/resque/pulls/1135"},"html":{"href":"https://github.com/resque/resque/pull/1135"},"issue":{"href":"https://api.github.com/repos/resque/resque/issues/1135"},"comments":{"href":"https://api.github.com/repos/resque/resque/issues/1135/comments"},"review_comments":{"href":"https://api.github.com/repos/resque/resque/pulls/1135/comments"},"review_comment":{"href":"https://api.github.com/repos/resque/resque/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/resque/resque/pulls/1135/commits"},"statuses":{"href":"https://api.github.com/repos/resque/resque/statuses/4b30fc274e58d73f7c1126de555972c973f16f6a"}},"merged":false,"mergeable":false,"mergeable_state":"dirty","merged_by":null,"comments":3,"review_comments":0,"commits":1,"additions":17,"deletions":0,"changed_files":2}}