【问题标题】:Whenever gem error - Could not find command "bin/rails"每当 gem 错误 - 找不到命令“bin/rails”
【发布时间】:2018-10-16 20:25:35
【问题描述】:

我正在尝试每 3 小时运行一次数据库备份。 问题是,我在 cron 日志中收到以下消息,而不是运行:

找不到命令“bin/rails”。

我的 schedule.rb 文件很简单:

set :bundle_command, "/usr/local/bin/bundle"

set :output, { error: '/usr/src/app/log/error.log', standard: '/usr/src/app/log/cron.log' }

require '/usr/src/app/lib/database_backup.rb'

every 2.minutes do

  runner "take_database_backup"

end

Rails 在 Docker 容器中运行。

知道是什么原因造成的吗?

【问题讨论】:

  • 如果只在容器的 bash 中运行脚本就可以了?

标签: ruby-on-rails docker bundler whenever


【解决方案1】:

您的schedule.rb 指定:bundle_command,因此您似乎打算让cronjob 使用/usr/local/bin/bundle exec ... 运行某些东西。

但是,:bundle_command 仅适用于job_type :rakejob_type :scriptjob_type :runner 解析为:

"cd :path && bin/rails runner -e :environment ':task' :output"

注意以上使用bin/rails,而不是bundle。所以很有可能,无论您的 :path 解析到什么地方,您的 bin/rails binstub 都会以某种方式丢失。默认情况下,:path 解析为执行whenever 的目录。

【讨论】:

    猜你喜欢
    • 2012-03-17
    • 1970-01-01
    • 2022-07-07
    • 1970-01-01
    • 2015-08-26
    • 2016-11-17
    • 2021-02-16
    • 2015-01-16
    • 2013-02-19
    相关资源
    最近更新 更多