【问题标题】:Gemfile not found using Cron job with Capistrano 3 and whenever gem使用 Capistrano 3 和每当 gem 的 Cron 作业时找不到 Gemfile
【发布时间】:2015-05-04 10:48:51
【问题描述】:

Cron 作业在我的电脑上运行良好。但是当我使用 capistrano 将它部署到服务器时。 cron.log 文件显示它正在寻找服务器上不存在的版本,我该如何解决这个问题。有什么想法...?

/home/deployer/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/bundler-1.7.2/lib/bundler/definition.rb:22:in `build': /home/deployer/apps/production_app/releases/20140906112257/Gemfile not found (Bundler::GemfileNotFound)
    from 

当我运行 crontab -e 命令时,它会显示到正确的版本

# Begin Whenever generated tasks for: production_app
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * /bin/bash -l -c 'cd /home/deployer/apps/production_app/releases/20150504102922 && bin/rails runner -e production '\''Vehicle.check_not_responding'\'' >> /home/deployer/apps/production_app/releases/20150504102922/log/cron.log 2>&1'

* * * * * /bin/bash -l -c 'cd /home/deployer/apps/production_app/releases/20150504102922 && bin/rails runner -e production '\''SmsDetail.send_sms'\'' >> /home/deployer/apps/production_app/releases/20150504102922/log/cron.log 2>&1'

# End Whenever generated tasks for: production_app

我该如何解决这个问题...?

【问题讨论】:

    标签: ruby-on-rails cron capistrano3 whenever


    【解决方案1】:

    前段时间我也遇到了同样的问题。事实证明,当 cron 尝试运行任务时,变量 BUNDLE_GEMFILE 没有定义。所以你需要在你的schedule.rb

    env :BUNDLE_GEMFILE, ENV["/#{path}/Gemfile"]
    

    env :BUNDLE_GEMFILE, ENV["/home/deployer/apps/production_app/current/Gemfile"]
    

    让我知道对你的情况有什么帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-20
      相关资源
      最近更新 更多