Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2012-12-26 02:14:00 +0400
committerJakub Jirutka <jakub@jirutka.cz>2012-12-26 02:14:00 +0400
commita1434ff50b7cc86e1e1a2863366e235da0f77cd7 (patch)
tree8d052bc31569ab37d3427064201ac8ef8307664c /config
parent4c800342afbd3077e863132006baf19a1d30069a (diff)
Fix shared Redis connection issue on Passenger
Diffstat (limited to 'config')
-rw-r--r--config/initializers/passenger_fix.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/config/initializers/passenger_fix.rb b/config/initializers/passenger_fix.rb
new file mode 100644
index 00000000000..3a88eb10a36
--- /dev/null
+++ b/config/initializers/passenger_fix.rb
@@ -0,0 +1,16 @@
+if defined?(PhusionPassenger)
+
+ # When you're using Passenger with smart-lv2 (default) or smart spawn method,
+ # Resque doesn't recognize that it has been forked and should re-establish
+ # Redis connection. You can see this error message in log:
+ # Redis::InheritedError, Tried to use a connection from a child process
+ # without reconnecting. You need to reconnect to Redis after forking.
+ #
+ # This solution is based on
+ # https://github.com/redis/redis-rb/wiki/redis-rb-on-Phusion-Passenger
+ #
+ PhusionPassenger.on_event(:starting_worker_process) do |forked|
+ # if we're in smart spawning mode, reconnect to Redis
+ Resque.redis.client.reconnect if forked
+ end
+end