job type defaults are now in setup.rb

This commit is contained in:
Javan Makhmali 2010-10-26 09:59:24 -04:00
parent 9f73bcb469
commit 974b5a2016
2 changed files with 6 additions and 6 deletions

View File

@ -16,12 +16,9 @@ module Whenever
pre_set(options[:set]) pre_set(options[:set])
end end
# Load all job type files. setup = File.read("#{File.expand_path(File.dirname(__FILE__))}/setup.rb")
Dir["#{File.expand_path(File.dirname(__FILE__))}/job_types/*.rb"].each do |file|
eval(File.read(file))
end
eval(config) eval(setup + config)
end end
def set(variable, value) def set(variable, value)

View File

@ -1,6 +1,9 @@
# Environemnt defaults to production
set :environment, "production" set :environment, "production"
# Path defaults to the directory `whenever` was run from
set :path, Whenever.path set :path, Whenever.path
# All jobs are wrapped in this template.
# http://blog.scoutapp.com/articles/2010/09/07/rvm-and-cron-in-production # http://blog.scoutapp.com/articles/2010/09/07/rvm-and-cron-in-production
set :job_template, "/bin/bash -l -c ':job'" set :job_template, "/bin/bash -l -c ':job'"
@ -8,7 +11,7 @@ job_type :command, ":task :output"
job_type :rake, "cd :path && RAILS_ENV=:environment rake :task --silent :output" job_type :rake, "cd :path && RAILS_ENV=:environment rake :task --silent :output"
# Create a runner job that's appropriate for the Rails version, # Create a runner job that's appropriate for the Rails version,
if File.exists?(File.join(Whenever.path, 'script', 'rails')) if File.exists?(File.join(path, 'script', 'rails'))
job_type :runner, "cd :path && script/rails runner -e :environment ':task' :output" job_type :runner, "cd :path && script/rails runner -e :environment ':task' :output"
else else
job_type :runner, "cd :path && script/runner -e :environment ':task' :output" job_type :runner, "cd :path && script/runner -e :environment ':task' :output"