Skip to content

Instantly share code, notes, and snippets.

@garrensmith
Created September 25, 2012 08:32
Show Gist options
  • Select an option

  • Save garrensmith/3780648 to your computer and use it in GitHub Desktop.

Select an option

Save garrensmith/3780648 to your computer and use it in GitHub Desktop.
Bluepill setup for Rails and Resque
ENV["RAILS_ENV"] = "staging"
Bluepill.application("my_app-staging", :log_file => '/var/my_app/shared/log/bluepill.log') do |app|
app.process("unicorn") do |process|
process.pid_file = '/var/my_app/shared/pids/unicorn.pid'
process.working_dir = '/var/my_app/current'
process.start_command = "/usr/local/bin/bundle exec unicorn -c /var/my_app/current/config/unicorn.rb -E staging -D"
process.stop_command = "kill -QUIT {{PID}}"
process.restart_command = "kill -USR2 {{PID}}"
process.uid = process.gid = 'deploy'
process.start_grace_time = 30.seconds
process.stop_grace_time = 30.seconds
process.restart_grace_time = 30.seconds
process.monitor_children do |child_process|
child_process.stop_command = "kill -QUIT {{PID}}"
child_process.checks :mem_usage, :every => 30.seconds, :below => 200.megabytes, :times => [3,4], :fires => :stop
child_process.checks :cpu_usage, :every => 30.seconds, :below => 40, :times => [3,4], :fires => :stop
end
end
2.times do |i|
app.process("resque-#{i}") do |process|
process.working_dir = '/var/my_app/current'
process.group = "resque"
process.start_command = "/usr/local/bin/bundle exec rake resque:work"
process.pid_file = "/var/my_app/shared/pids/my_app-resque-#{i}.pid"
process.stop_command = "kill -QUIT {{PID}}"
process.daemonize = true
process.start_grace_time = 30.seconds
process.stop_grace_time = 30.seconds
process.uid = process.gid = 'deploy'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment