diff options
author | Jonne Haß <me@jhass.eu> | 2015-05-17 19:43:57 +0300 |
---|---|---|
committer | Dennis Schubert <mail@dennis-schubert.de> | 2015-05-19 03:55:01 +0300 |
commit | a21de8b190a39753aea838e982a606340342e0e5 (patch) | |
tree | c82c09f4bb9361a8a9dbcb6f6380b2f038baa3bb /config/unicorn.rb | |
parent | a396a246ee53c206383f9527a91dae74db8381b5 (diff) |
Make listen directive for Unicorn configurable
Diffstat (limited to 'config/unicorn.rb')
-rw-r--r-- | config/unicorn.rb | 45 |
1 files changed, 12 insertions, 33 deletions
diff --git a/config/unicorn.rb b/config/unicorn.rb index 28ee4afc7..0dfabe003 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -1,29 +1,19 @@ -require File.expand_path('../load_config', __FILE__) +require_relative "load_config" -# Enable and set these to run the worker as a different user/group -#user = 'diaspora' -#group = 'diaspora' +port = ENV["PORT"] +port = port && !port.empty? ? port.to_i : nil +listen port || AppConfig.server.listen.get unless RACKUP[:set_listener] worker_processes AppConfig.server.unicorn_worker.to_i - -## Load the app before spawning workers -preload_app true - -# How long to wait before killing an unresponsive worker timeout AppConfig.server.unicorn_timeout.to_i - -@sidekiq_pid = nil - -#pid '/var/run/diaspora/diaspora.pid' -#listen '/var/run/diaspora/diaspora.sock', :backlog => 2048 - - stderr_path AppConfig.server.stderr_log.get if AppConfig.server.stderr_log? stdout_path AppConfig.server.stdout_log.get if AppConfig.server.stdout_log? -before_fork do |server, worker| - # If using preload_app, enable this line - ActiveRecord::Base.connection.disconnect! +preload_app true +@sidekiq_pid = nil + +before_fork do |_server, _worker| + ActiveRecord::Base.connection.disconnect! # preloading app in master, so reconnect to DB # disconnect redis if in use unless AppConfig.environment.single_process_mode? @@ -31,23 +21,12 @@ before_fork do |server, worker| end if AppConfig.server.embed_sidekiq_worker? - @sidekiq_pid ||= spawn('bin/bundle exec sidekiq') - end - - old_pid = '/var/run/diaspora/diaspora.pid.oldbin' - if File.exists?(old_pid) && server.pid != old_pid - begin - Process.kill("QUIT", File.read(old_pid).to_i) - rescue Errno::ENOENT, Errno::ESRCH - # someone else did our job for us - end + @sidekiq_pid ||= spawn("bin/bundle exec sidekiq") end end - -after_fork do |server, worker| - # If using preload_app, enable this line - ActiveRecord::Base.establish_connection +after_fork do |_server, _worker| + ActiveRecord::Base.establish_connection # preloading app in master, so reconnect to DB # We don't generate uuids in the frontend, but let's be on the safe side UUID.generator.next_sequence |