[英]Rails gem : javan whenever failing
Trying to set up javan Whenever gem. 尝试设置javan每当gem。
Have the 0.8.4 version installed. 已安装0.8.4版本。
schedule.rb looks like this : schedule.rb看起来像这样:
if Rails.env == 'production'
set :output, "#{::Rails.root.to_s}/tmp/cron.log"
every '*/1 * * * *' do
command "bundle exec rake ts:reindex RAILS_ENV=production"
end
end
When I do a 'whenever' I get : 当我执行“无论何时”时,我都会得到:
/home/slagrz/.rvm/gems/ruby-1.9.3-p448/gems/whenever-0.6.8/lib/whenever/job_list.rb:21:in `eval': uninitialized constant Whenever::JobList::Rails (NameError)
from /home/slagrz/.rvm/gems/ruby-1.9.3-p448/gems/whenever-0.6.8/lib/whenever/job_list.rb:21:in `eval'
from /home/slagrz/.rvm/gems/ruby-1.9.3-p448/gems/whenever-0.6.8/lib/whenever/job_list.rb:21:in `initialize'
from /home/slagrz/.rvm/gems/ruby-1.9.3-p448/gems/whenever-0.6.8/lib/whenever.rb:15:in `new'
from /home/slagrz/.rvm/gems/ruby-1.9.3-p448/gems/whenever-0.6.8/lib/whenever.rb:15:in `cron'
from /home/slagrz/.rvm/gems/ruby-1.9.3-p448/gems/whenever-0.6.8/lib/whenever/command_line.rb:41:in `run'
from /home/slagrz/.rvm/gems/ruby-1.9.3-p448/gems/whenever-0.6.8/lib/whenever/command_line.rb:8:in `execute'
from /home/slagrz/.rvm/gems/ruby-1.9.3-p448/gems/whenever-0.6.8/bin/whenever:38:in `<top (required)>'
from /home/slagrz/.rvm/gems/ruby-1.9.3-p448/bin/whenever:23:in `load'
from /home/slagrz/.rvm/gems/ruby-1.9.3-p448/bin/whenever:23:in `<main>'
from /home/slagrz/.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in `eval'
from /home/slagrz/.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in `<main>'
So, just wondering if I have wrong versions installed or if the format of the schedule file is affecting it. 因此,只是想知道我是否安装了错误的版本,或者计划文件的格式是否正在影响它。
Thanks 谢谢
On further investigation I commented out lines as follows and its working now from the command line. 在进一步调查中,我注释了以下几行,现在从命令行对其进行了工作。
#if Rails.env == 'production'
# set :output, "#{::Rails.root.to_s}/tmp/cron.log"
every '*/1 * * * *' do
command "bundle exec rake ts:reindex RAILS_ENV=production"
end
#end
I think this was intented for use with capistrano originally.. maybe? 我认为这原本打算与capistrano一起使用。 Thanks
谢谢
I was getting same error in my rails 4.1 application for below code: 我在Rails 4.1应用程序中遇到以下代码相同的错误:
every 1.day, :at => '8:30 am' do
rake 'update_hotels', environment: Rails.env
end
I tried updating crontab with whenever command ( whenever --update-crontab ) and got the error. 我尝试使用每当命令(每当--update-crontab)更新crontab并收到错误。
I managed to get it working by removing environment part ( environment: Rails.env ). 我设法通过删除环境部分(environment:Rails.env)使它正常工作。
However I had to manually update crontab as it generated entries for production environment but I was trying this in staging. 但是,我必须手动更新crontab,因为它会为生产环境生成条目,但是我正在暂存中尝试此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.