Created
May 10, 2017 13:19
-
-
Save dipaktc/d45ab80a1a40e2dd163da7a622c7f273 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env = ENV["RAILS_ENV"] || "development" | |
if env == "production" | |
app_dir = "PROJECT-NAME" | |
worker_processes 4 | |
end | |
listen 8080, reuseport: true | |
preload_app true | |
timeout 30 | |
working_directory "/home/dev/PROJECT-NAME/current/" | |
# feel free to point this anywhere accessible on the filesystem | |
user 'dev', 'dev' | |
shared_path = "/home/dev/PROJECT-NAME/shared" | |
stderr_path "#{shared_path}/log/unicorn.stderr.log" | |
stdout_path "#{shared_path}/log/unicorn.stdout.log" | |
# pid "#{working_directory}/tmp/pids/unicorn.pid" | |
before_fork do |server, worker| | |
if defined?(ActiveRecord::Base) | |
ActiveRecord::Base.connection.disconnect! | |
end | |
old_pid = "/home/dev/PROJECT-NAME/current/tmp/pids/unicorn.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 | |
end | |
end | |
end | |
after_fork do |server, worker| | |
if defined?(ActiveRecord::Base) | |
ActiveRecord::Base.establish_connection | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment