From b9f62c6382cb04002285e2e6c056ff4e35217ba8 Mon Sep 17 00:00:00 2001 From: Manson Wang Date: Thu, 13 Feb 2014 17:28:12 +0800 Subject: [PATCH] Fix Resque "Internal Server Error" issue in pushion passenger forked environment --- config/initializers/redis.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 config/initializers/redis.rb diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb new file mode 100644 index 0000000..c77dfe9 --- /dev/null +++ b/config/initializers/redis.rb @@ -0,0 +1,11 @@ +if defined?(PhusionPassenger) + PhusionPassenger.on_event(:starting_worker_process) do |forked| + if forked + Resque.redis.client.disconnect + Resque.redis = Redis.new(:host => 'localhost', :port => 6379) + Resque.redis.namespace = Site.first.resque_namespace rescue APP_CONFIG['orbit'] + else + # We're in conservative spawning mode. We don't need to do anything. + end + end +end \ No newline at end of file