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 + +