Skip to content
Extraits de code Groupes Projets
Valider 95b7e30e rédigé par danielgrippi's avatar danielgrippi
Parcourir les fichiers

preload_app in unicorn

parent ff71bc5a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -7,7 +7,7 @@ rails_env = ENV['RAILS_ENV'] || 'development'
worker_processes 1
## Load the app before spawning workers
#preload_app true
preload_app true
# How long to wait before killing an unresponsive worker
timeout 30
......@@ -23,7 +23,12 @@ end
before_fork do |server, worker|
# If using preload_app, enable this line
#ActiveRecord::Base.disconnect!
ActiveRecord::Base.connection.disconnect!
# disconnect redis if in use
if !AppConfig.single_process_mode?
Resque.redis.client.disconnect
end
old_pid = '/var/run/diaspora/diaspora.pid.oldbin'
if File.exists?(old_pid) && server.pid != old_pid
......@@ -38,7 +43,17 @@ end
after_fork do |server, worker|
# If using preload_app, enable this line
# ActiveRecord::Base.establish_connection
ActiveRecord::Base.establish_connection
# copy pasta from resque.rb because i'm a bad person
if !AppConfig.single_process_mode?
if redis_to_go = ENV["REDISTOGO_URL"]
uri = URI.parse(redis_to_go)
Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
elsif AppConfig[:redis_url]
Resque.redis = Redis.new(:host => AppConfig[:redis_url], :port => 6379)
end
end
# Enable this line to have the workers run as different user/group
#worker.user(user, group)
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter