public
Last active

Bluepill used at Halftoneapp.com

  • Download Gist
Bluepill Uncorn Config File
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
#
# Halftoneapp.com Sample Bluepill Configuration File
# Read more at: http://blog.halftoneapp.com
#
 
# Set paths
home_dir = "/home/railsapp"
rails_shared = "#{home_dir}/app/shared"
unicorn_path = "/path/to/unicorn_rails"
 
# Set environment variables
rails_env = ENV['RAILS_ENV'] || 'production'
rails_root = ENV['RAILS_ROOT'] || "#{home_dir}/app/current"
 
 
Bluepill.application("railsapp", :log_file => rails_root+"/log/bluepill.log") do |app|
app.process("unicorn") do |process|
 
## THE APPLICATION ##
## -----------------
 
# Set Unicorn PID file
process.pid_file = File.join(rails_root, 'tmp', 'pids', 'unicorn.pid')
process.working_dir = "#{rails_root}"
 
# Set the command line argument to START Unicorn.
process.start_command = "#{unicorn_path} -Dc #{home_dir}/unicorn.conf.rb -E #{rails_env}"
 
# Set the command line argument to STOP Unicorn.
process.stop_command = "kill -QUIT {{PID}}"
 
# Set the command line argument to RESTART Unicorn. (The USR2 causes the master to re-create itself and spawn a new worker pool)
process.restart_command = "kill -USR2 {{PID}}"
 
## GRACE PERIODS ##
## -----------------
 
# After we start the app, how long should we wait until we start monitoring the application
process.start_grace_time = 3.seconds
 
# Same as above, grace period after we've restarted the application
process.restart_grace_time = 8.seconds
 
## APPLICATION CHECKS
## -----------------
process.checks :cpu_usage, :every => 10.seconds, :below => 30, :times => 3
process.checks :mem_usage, :every => 10.seconds, :below => 500.megabytes, :times => [3,5]
 
## SETUP UNICORN CHILDREN MONITORING
## -----------------
process.monitor_children do |child_process|
child_process.checks :cpu_usage, :every => 10, :below => 25, :times => 3
child_process.checks :mem_usage, :every => 10, :below => 200.megabytes, :times => [3, 5]
child_process.stop_command = "kill -QUIT {{PID}}"
end
end
end

NOTE: If your unicorn config file has preload_app defined as true then 'restart_command' will not load in any new code. See SIGNALS for more info: http://unicorn.bogomips.org/SIGNALS.html

@shilov, i could be mistaken , but I think you're getting confused with the HUP signal...

see this quote:

HUP - reloads config file and gracefully restart all workers. If the “preload_app” directive is false (the default), then workers will also pick up any application code changes when restarted. If “preload_app” is true, then application code changes will have no effect; USR2 + QUIT

He's sending USR2 on restart, so I'd assume he has something in config/unicorn.rb that's sending the QUIT

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.