From b4be5da97c497d37535aad717075759582ba853f Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 3 Feb 2014 19:27:27 +0100 Subject: [PATCH] Improved error handling. --- script/scheduler.rb | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/script/scheduler.rb b/script/scheduler.rb index aa95c9267..d35a44ccc 100755 --- a/script/scheduler.rb +++ b/script/scheduler.rb @@ -14,9 +14,9 @@ daemon_options = { :backtrace => true } -worker_count = 2 +runner_count = 2 -(1..worker_count).each {|count| +(1..runner_count).each {|count| name = 'scheduler_runner' + count.to_s Daemons.run_proc(name, daemon_options) do if ARGV.include?('--') @@ -33,6 +33,27 @@ worker_count = 2 require File.join(dir, "config", "environment") require 'scheduler' - Scheduler.run(count, worker_count) + Scheduler.run(count, runner_count) end } + +name = 'scheduler_worker' +Daemons.run_proc(name, daemon_options) do + if ARGV.include?('--') + ARGV.slice! 0..ARGV.index('--') + else + ARGV.clear + end + + Dir.chdir dir + RAILS_ENV = ARGV.first || ENV['RAILS_ENV'] || 'development' + + $stdout.reopen( dir + "/log/" + name + "_out.log", "w") + $stderr.reopen( dir + "/log/" + name + "_err.log", "w") + require File.join(dir, "config", "environment") + require 'scheduler' + + Scheduler.worker +end + +