Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Bluepill used at
# Sample Bluepill Configuration File
# Read more at:
# 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|
## -----------------
# Set Unicorn PID file
process.pid_file = File.join(rails_root, 'tmp', 'pids', '')
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}}"
## -----------------
# 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
## -----------------
process.checks :cpu_usage, :every => 10.seconds, :below => 30, :times => 3
process.checks :mem_usage, :every => 10.seconds, :below => 500.megabytes, :times => [3,5]
## -----------------
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}}"
shilov commented Jun 8, 2011

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:

taf2 commented Sep 1, 2011

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.