Add CLI#run_job

This commit is contained in:
Dzmitry Plashchynski
2015-03-03 14:36:00 +02:00
parent 5efd2681d0
commit 2c78115ce7
3 changed files with 24 additions and 2 deletions

View File

@@ -7,8 +7,10 @@ module Crono
def run
load_rails
print_banner
# start_working_loop
end
private
def print_banner
puts "Loading Crono #{Crono::VERSION}"
puts "Running in #{RUBY_DESCRIPTION}"
@@ -19,5 +21,15 @@ module Crono
require File.expand_path("config/environment.rb")
::Rails.application.eager_load!
end
def run_job(klass)
Thread.new { klass.new.perform }
end
def start_working_loop
Config.instance.schedule.each do |klass, period|
run_job(klass)
end
end
end
end