Created
May 23, 2012 11:14
-
-
Save bsodmike/2774625 to your computer and use it in GitHub Desktop.
Resque + Bluepill Nirvana
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'resque-ensure-connected' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add as an initializer | |
Resque.after_fork do |job| | |
ActiveRecord::Base.establish_connection | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add upstart script to load bluepill as follows:
YMMV.