From 6f46a3f949cd7848231923e41fb719c3da85dd21 Mon Sep 17 00:00:00 2001 From: "Matt K. Fu" Date: Wed, 19 Jun 2013 16:11:16 +0800 Subject: [PATCH 1/4] add god to monit sold --- config/resque.god | 6 ++-- config/resque_schedule.god | 8 +++--- config/solr.god | 57 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 config/solr.god diff --git a/config/resque.god b/config/resque.god index 9549f2a7..4985aba4 100644 --- a/config/resque.god +++ b/config/resque.god @@ -10,8 +10,8 @@ num_workers.times do |num| God.watch do |w| w.dir = rails_root - w.name = "worker-#{num}" - w.group = 'resque' + w.name = "resque-worker-#{num}" + w.group = 'rulingcom' w.interval = 30.seconds @@ -30,7 +30,7 @@ num_workers.times do |num| w.uid = (rails_env == 'production' )? "root" : development_uid w.gid = (rails_env == 'production' )? "root" : development_gid - w.log = (rails_env == 'production' )? "/var/log/#{w.group}/#{w.name}.log":"#{rails_root}/log/dev_resque-#{w.name}.log" + w.log = (rails_env == 'production' )? "/var/log/#{w.group}/#{w.name}.log":"#{rails_root}/log/dev-#{w.name}.log" # restart if memory gets too high w.transition(:up, :restart) do |on| diff --git a/config/resque_schedule.god b/config/resque_schedule.god index 696a2fd0..0c0fef7e 100644 --- a/config/resque_schedule.god +++ b/config/resque_schedule.god @@ -6,16 +6,16 @@ development_gid = '' God.watch do |w| w.dir = rails_root - w.name = "scheduler" - w.group = 'resque' + w.name = "resque-scheduler" + w.group = 'rulingcom' w.interval = 30.seconds w.env = {"QUEUE"=>"critical,high,low", "RAILS_ENV"=>rails_env} - w.start = "HOME= #{user_home} QUEUE=* RAILS_ENV=#{rails_env} rake -f #{rails_root}/Rakefile resque:scheduler" + w.start = "HOME=#{user_home} QUEUE=* RAILS_ENV=#{rails_env} rake -f #{rails_root}/Rakefile resque:scheduler" w.uid = (rails_env == 'production' )? "root" : development_uid w.gid = (rails_env == 'production' )? "root" : development_gid - w.log = (rails_env == 'production' )? "/var/log/#{w.group}/#{w.name}.log":"#{rails_root}/log/dev_resque-#{w.name}.log" + w.log = (rails_env == 'production' )? "/var/log/#{w.group}/#{w.name}.log":"#{rails_root}/log/dev-#{w.name}.log" # restart if memory gets too high w.transition(:up, :restart) do |on| diff --git a/config/solr.god b/config/solr.god new file mode 100644 index 00000000..73304e4e --- /dev/null +++ b/config/solr.god @@ -0,0 +1,57 @@ +rails_env = ENV['RAILS_ENV'] || "production" +rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/..' +user_home = ENV['HOME'] || File.dirname(__FILE__) + '/../..' +development_uid = '' +development_gid = '' + + God.watch do |w| + w.dir = rails_root + w.name = "scheduler" + w.group = 'rulingcom' + w.interval = 30.seconds + w.env = {"RAILS_ENV"=>rails_env} + w.start = "HOME=#{user_home} RAILS_ENV=#{rails_env} rake -f #{rails_root}/Rakefile sunspot:solr:start" + + w.uid = (rails_env == 'production' )? "root" : development_uid + w.gid = (rails_env == 'production' )? "root" : development_gid + + w.log = (rails_env == 'production' )? "/var/log/#{w.group}/#{w.name}.log":"#{rails_root}/log/dev-#{w.name}.log" + + # restart if memory gets too high + w.transition(:up, :restart) do |on| + on.condition(:memory_usage) do |c| + c.above = 350.megabytes + c.times = 2 + end + end + + # determine the state on startup + w.transition(:init, { true => :up, false => :start }) do |on| + on.condition(:process_running) do |c| + c.running = true + end + end + + # determine when process has finished starting + w.transition([:start, :restart], :up) do |on| + on.condition(:process_running) do |c| + c.running = true + c.interval = 5.seconds + end + + # failsafe + on.condition(:tries) do |c| + c.times = 5 + c.transition = :start + c.interval = 5.seconds + end + end + + # start if process is not running + w.transition(:up, :start) do |on| + on.condition(:process_running) do |c| + c.running = false + end + end + end + From c4ec6c1ac93215a6592923f3f33e7c4713b890ea Mon Sep 17 00:00:00 2001 From: "Matt K. Fu" Date: Wed, 19 Jun 2013 16:24:56 +0800 Subject: [PATCH 2/4] fix solr name --- config/solr.god | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/solr.god b/config/solr.god index 73304e4e..dbb4806b 100644 --- a/config/solr.god +++ b/config/solr.god @@ -6,7 +6,7 @@ development_gid = '' God.watch do |w| w.dir = rails_root - w.name = "scheduler" + w.name = "sunspot-solr" w.group = 'rulingcom' w.interval = 30.seconds w.env = {"RAILS_ENV"=>rails_env} From cd55f2aac2669d41f6d9096446d33d98cdbc0097 Mon Sep 17 00:00:00 2001 From: "Matt K. Fu" Date: Wed, 19 Jun 2013 19:23:45 +0800 Subject: [PATCH 3/4] fix solr setting --- config/solr.god | 8 ++++---- config/sunspot.yml | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config/solr.god b/config/solr.god index dbb4806b..10bb2e33 100644 --- a/config/solr.god +++ b/config/solr.god @@ -10,12 +10,12 @@ development_gid = '' w.group = 'rulingcom' w.interval = 30.seconds w.env = {"RAILS_ENV"=>rails_env} - w.start = "HOME=#{user_home} RAILS_ENV=#{rails_env} rake -f #{rails_root}/Rakefile sunspot:solr:start" - + w.start = "HOME=#{user_home} QUEUE=* RAILS_ENV=#{rails_env} rake -f #{rails_root}/Rakefile sunspot:solr:start" + w.keepalive w.uid = (rails_env == 'production' )? "root" : development_uid w.gid = (rails_env == 'production' )? "root" : development_gid - - w.log = (rails_env == 'production' )? "/var/log/#{w.group}/#{w.name}.log":"#{rails_root}/log/dev-#{w.name}.log" + w.pid_file = "#{rails_root}/solr/pids/production/sunspot-solr-production.pid" + w.log = (rails_env == 'production' )? "/var/log/#{w.group}/#{w.name}.log":"#{rails_root}/log/dev-#{w.name}.log" # restart if memory gets too high w.transition(:up, :restart) do |on| diff --git a/config/sunspot.yml b/config/sunspot.yml index e8323e42..94c95bc3 100644 --- a/config/sunspot.yml +++ b/config/sunspot.yml @@ -2,6 +2,7 @@ production: solr: hostname: localhost port: 8982 + path: '/solr/orbit' #solr dic log_level: WARNING development: From 1268ce0ae9aa0842b433ad18a6d4c8c979454ad5 Mon Sep 17 00:00:00 2001 From: "Matt K. Fu" Date: Thu, 20 Jun 2013 17:42:00 +0800 Subject: [PATCH 4/4] remove useless setting for solar --- config/sunspot.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/config/sunspot.yml b/config/sunspot.yml index 94c95bc3..e8323e42 100644 --- a/config/sunspot.yml +++ b/config/sunspot.yml @@ -2,7 +2,6 @@ production: solr: hostname: localhost port: 8982 - path: '/solr/orbit' #solr dic log_level: WARNING development: