ENV["RAILS_ENV"] = "<%= stage %>" Bluepill.application("<%= application %>-<%= stage %>", :log_file => '<%= log_file %>') do |app| app.process("unicorn") do |process| process.pid_file = '<%= unicorn_config_path %>' 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