#! /usr/bin/env ruby # -*- encoding: utf-8 -*- require 'evented_bluepill' ROOT_DIR = "/tmp/bp" # Watch with # watch -n0.2 'ps axu | egrep "(CPU|forking|evented_bluepill|sleep)" | grep -v grep | sort' EventedBluepill.application(:sample_app, :foreground => true, :log_file => '/tmp/bp/sample_app.log') do |app| 1.times do |i| app.process("process_#{i}") do |process| process.pid_file = "#{ROOT_DIR}/pids/process_#{i}.pid" # I could not figure out a portable way to # specify the path to the sample forking server across the diff developer laptops. # Since this code is eval'ed we cannot reliably use __FILE__ process.start_command = "/Users/stefan/Documents/projects/evented_bluepill/example/sample_forking_server #{4242 + i}" process.stop_command = "kill -INT {{PID}}" process.daemonize = true process.start_grace_time = 1.seconds process.restart_grace_time = 7.seconds process.stop_grace_time = 7.seconds process.uid = "stefan" process.gid = "staff" process.group = "test" process.checks :cpu_usage, :every => 5, :below => 0.5, :times => [5, 5] process.checks :flapping, :times => 2, :within => 30.seconds, :retry_in => 20.seconds process.monitor_children do |child_process| child_process.checks :cpu_usage, :every => 10, :below => 0.5, :times => [5, 5] child_process.checks :mem_usage, :every => 3, :below => 900.kilobytes, :times => [3, 5], :fires => :stop child_process.stop_command = "kill -QUIT {{PID}}" # child_process.checks :flapping, :times => 2, :within => 30.seconds, :retry_in => 7.seconds end end end 0.times do |i| app.process("group_process_#{i}") do |process| process.group = "group_1" process.pid_file = "/Users/rohith/ffs/tmp/pids/mongrel_#{i}.pid" process.start_command = "cd ~/ffs && mongrel_rails start -P #{process.pid_file} -p 3000 -d" process.start_grace_time = 10.seconds process.uid = "rohith" process.gid = "staff" # process.checks :always_true, :every => 10 end end 0.times do |i| app.process("group_process_#{i}") do |process| process.uid = "rohith" process.gid = "wheel" process.stderr = "/tmp/err.log" process.stdout = "/tmp/err.log" process.group = "grouped" process.start_command = %Q{cd /tmp && ruby -e '$stderr.puts("hello stderr");$stdout.puts("hello stdout"); $stdout.flush; $stderr.flush; sleep 10'} process.daemonize = true process.pid_file = "/tmp/noperm/p_#{process.group}_#{i}.pid" # process.checks :always_true, :every => 5 end end end