Skip to content

@jamsi /Bluepill Uncorn Config File
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Bluepill used at Halftoneapp.com
#
# 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
@shilov

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

@taf2

@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.