Skip to content

Instantly share code, notes, and snippets.

@bsodmike
Created May 23, 2012
Embed
What would you like to do?
Resque + Bluepill Nirvana
gem 'resque-ensure-connected'
# add as an initializer
Resque.after_fork do |job|
ActiveRecord::Base.establish_connection
end
RAILS_ROOT = ENV['RAILS_ROOT'] || "/home/appuser/sites/foo"
RAILS_ENV = 'production'
Bluepill.application("app_name", :log_file => "/home/appuser/sites/foo/log/resque_workers.log") do |app|
app.uid = app.gid = "appuser"
5.times do |i|
app.process("resque_worker_#{i}") do |process|
process.working_dir = RAILS_ROOT
process.group = "resque"
process.pid_file = "/home/appuser/sites/foo/tmp/resque_worker_#{i}.pid"
process.start_command = "/usr/bin/env VERBOSE=true RAILS_ENV=#{RAILS_ENV} QUEUE=* rake resque:work --trace"
process.stop_command = "kill -QUIT {{PID}}"
process.monitor_children do |c|
c.stop_command = "kill -USR1 {{PID}}"
c.checks :mem_usage, :every => 30.seconds, :below => 100.megabytes, :fires => :stop
end
process.daemonize = true
process.start_grace_time = 3.seconds
process.stop_grace_time = 5.seconds
process.restart_grace_time = 8.seconds
process.checks :mem_usage, :below => 350.megabytes, :every => 1.minute, :times => 3
end
end
end
@bsodmike

This comment has been minimized.

Copy link
Owner Author

@bsodmike bsodmike commented May 23, 2012

Add upstart script to load bluepill as follows:

bluepill load /home/appuser/sites/foo/config/resque.pill

YMMV.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment