Commit 49635f2d

mo khan <mo@mokhan.ca>
2013-07-30 04:01:27
add monit configuration for delayed job
1 parent f6f45b6
Changed files (3)
config
config/recipes/templates/monit/delayed_job.erb
@@ -0,0 +1,6 @@
+check process delayed_job with pidfile <%= delayed_job_pid %>
+  start program = "/etc/init.d/delayed_job_<%= application %> start"
+  stop program = "/etc/init.d/delayed_job_<%= application %> stop"
+  if mem > 200.0 MB for 1 cycle then restart
+  if cpu > 50% for 3 cycles then restart
+  if 5 restarts within 5 cycles then timeout
config/recipes/delayed_job.rb
@@ -1,3 +1,5 @@
+set_default(:delayed_job_pid) { "#{shared_path}/pids/delayed_job.pid" }
+
 namespace :delayed_job do 
   desc "setup delayed job"
   task :setup, roles: :app do
config/recipes/monit.rb
@@ -11,6 +11,7 @@ namespace :monit do
     nginx
     postgresql
     unicorn
+    delayed_job
     syntax
     reload
   end
@@ -19,6 +20,7 @@ namespace :monit do
   task(:nginx, roles: :web) { monit_config "nginx" }
   task(:postgresql, roles: :db) { monit_config "postgresql" }
   task(:unicorn, roles: :app) { monit_config "unicorn" }
+  task(:delayed_job, roles: :app) { monit_config "delayed_job" }
 
   %w[start stop restart syntax reload].each do |command|
     desc "run monit #{command} script"