$ bundle exec whenever --update-crontab appname --set environment=production
このように処理を実行した時、schedule.rb の中では、ENV['RAILS_ENV'] で取得できない。
$ config/schedule.rb
require File.expand_path(File.dirname(__FILE__) + "/environment") require "yaml" RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + "/..") unless defined?(RAILS_ROOT) CONFIG = YAML.load_file(RAILS_ROOT + "/config/schedule.yml")[@environment] set :output, 'log/cron.log' every 1.minute do command "curl #{CONFIG['value']} --tlsv1.0 -k" end
$ config/schedule.yml
development: request: "http://batch/push" test: value: "http://batch/push/hoge" staging: value: "http://batch/push" production: value: "http://aa/batch/push"