ruby-on-rails - Rails 每当 gem 在通过 capistrano 部署时出错

标签 ruby-on-rails ruby-on-rails-3 cron whenever whenever-capistrano

我正在尝试通过 whenever gem 为 Rails 项目创建我的第一个 cron 作业。运行 cap deploy 时,出现此错误:

...
* 2013-01-01 22:29:00 executing `whenever:update_crontab'
  * executing "cd /var/www/vhosts/famnfo.com/releases/20130102042834 && bundle exec whenever --update-crontab FamNFo --set environment=production --roles db"
    servers: ["famnfo.com"]
    [famnfo.com] executing command
 ** [out :: famnfo.com] /var/www/vhosts/famnfo.com/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/core_ext/numeric/time.rb:49:in `days': wrong number of arguments (1 for 0) (ArgumentError)
 ** [out :: famnfo.com] from config/schedule.rb:23:in `initialize'
 ** [out :: famnfo.com] from /var/www/vhosts/famnfo.com/shared/bundle/ruby/1.9.1/gems/whenever-0.8.1/lib/whenever/job_list.rb:25:in `instance_eval'
 ** [out :: famnfo.com] from /var/www/vhosts/famnfo.com/shared/bundle/ruby/1.9.1/gems/whenever-0.8.1/lib/whenever/job_list.rb:25:in `initialize'
 ** [out :: famnfo.com] from /var/www/vhosts/famnfo.com/shared/bundle/ruby/1.9.1/gems/whenever-0.8.1/lib/whenever.rb:15:in `new'
 ** [out :: famnfo.com] from /var/www/vhosts/famnfo.com/shared/bundle/ruby/1.9.1/gems/whenever-0.8.1/lib/whenever.rb:15:in `cron'
 ** [out :: famnfo.com] from /var/www/vhosts/famnfo.com/shared/bundle/ruby/1.9.1/gems/whenever-0.8.1/lib/whenever/command_line.rb:55:in `whenever_cron'
 ** [out :: famnfo.com] from /var/www/vhosts/famnfo.com/shared/bundle/ruby/1.9.1/gems/whenever-0.8.1/lib/whenever/command_line.rb:106:in `updated_crontab'
 ** [out :: famnfo.com] from /var/www/vhosts/famnfo.com/shared/bundle/ruby/1.9.1/gems/whenever-0.8.1/lib/whenever/command_line.rb:36:in `run'
 ** [out :: famnfo.com] from /var/www/vhosts/famnfo.com/shared/bundle/ruby/1.9.1/gems/whenever-0.8.1/lib/whenever/command_line.rb:7:in `execute'
 ** [out :: famnfo.com] from /var/www/vhosts/famnfo.com/shared/bundle/ruby/1.9.1/gems/whenever-0.8.1/bin/whenever:41:in `<top (required)>'
 ** [out :: famnfo.com] from /var/www/vhosts/famnfo.com/shared/bundle/ruby/1.9.1/bin/whenever:19:in `load'
 ** [out :: famnfo.com] from /var/www/vhosts/famnfo.com/shared/bundle/ruby/1.9.1/bin/whenever:19:in `<main>'
    command finished in 2308ms
*** [deploy:update_code] rolling back
...

这是我的 schedule.rb 代码:

set :output, "#{path}/log/cron.log"

every 1.day :at => "8:00am" do
    runner "BirthdayReminders.send_birthday_email_reminders"
end

我已将其添加到我的 capistrano deploy.rb 文件中

set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"

最佳答案

set :output, "#{path}/log/cron.log"

every 1.day :at => "8:00am" do
    runner "BirthdayReminders.send_birthday_email_reminders"
end

尝试在天后添加一个逗号:

every 1.day, :at => "8:00am" do
  ...

关于ruby-on-rails - Rails 每当 gem 在通过 capistrano 部署时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14116870/

相关文章:

ruby-on-rails - Rails 上的 Paypal 自适应支付给出错误的成功

ruby-on-rails - Rails+resque 后台作业导入不向数据库添加任何内容

ruby-on-rails - 如何使虚拟属性成为 bool 字段

linux - Crontab 在半点开始

ruby-on-rails - 关于Rails中@的使用

ruby-on-rails - 如何使用 accepts_nested_attributes_for 在连接表中创建 > 1 个相关对象?

ruby-on-rails-3 - will_paginate 3.0.3 和 data-remote

jquery - 使用 jQuery 渲染部分集合

ssh - 带有自定义 “--files-from”参数的cron无法运行rsync

ubuntu - 如何使用系统启动运行软件 - ubuntu