Skip to content

Instantly share code, notes, and snippets.

@baroldgene
Created April 2, 2013 18:54
Show Gist options
  • Save baroldgene/5295088 to your computer and use it in GitHub Desktop.
Save baroldgene/5295088 to your computer and use it in GitHub Desktop.
Bluepill Configuration
class NeverUnmonitor < Bluepill::Trigger
def notify(transition)
if transition.to_name == :unmonitored
dispatch!(:stop)
schedule_event(:start, 20)
end
end
end
Bluepill.application('room') do |app|
app_path = "/room-reservation" # ENV['RAILS_RELATIVE_URL_ROOT'] || '/'
# Set environment variables
rails_root = File.expand_path('../', File.dirname(__FILE__))
rails_env = ENV['RAILS_ENV'] || 'production'
app.working_dir = rails_root
app.process('unicorn') do |process|
process.pid_file = "#{rails_root}/tmp/pids/unicorn.pid"
process.start_command = "unicorn_rails -D -c config/unicorn.rb -E #{rails_env} --path #{app_path}"
process.stop_command = "kill -QUIT {{PID}}"
process.auto_start = true
process.start_grace_time = 10.seconds
process.stop_grace_time = 10.seconds
process.restart_grace_time = 10.seconds
process.checks :never_unmonitor
process.monitor_children do |child_process|
child_process.checks :cpu_usage, :every => 10, :below => 30, :times => 3
child_process.checks :mem_usage, :every => 10, :below => 200.megabytes, :times => 3
child_process.stop_command = "kill -QUIT {{PID}}"
end
end
app.process('delayed_job') do |process|
process.pid_file = "#{rails_root}/tmp/pids/delayed_job.pid"
process.auto_start = true
process.start_grace_time = 30.seconds
process.stop_grace_time = 10.seconds
process.restart_grace_time = 40.seconds
process.checks :never_unmonitor
process.start_command = "script/delayed_job start"
process.stop_command = "script/delayed_job stop"
process.checks :cpu_usage, :every => 10, :below => 30, :times => 3
process.checks :mem_usage, :every => 10, :below => 200.megabytes, :times => 3
end
app.process('clockwork') do |process|
process.auto_start = true
process.start_grace_time = 30.seconds
process.stop_grace_time = 10.seconds
process.restart_grace_time = 40.seconds
process.checks :never_unmonitor
process.pid_file = "#{rails_root}/tmp/pids/clockwork.pid"
process.start_command = "ruby config/clockwork_control.rb start"
process.stop_command = "kill -QUIT {{PID}}"
process.checks :cpu_usage, :every => 10, :below => 30
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment