简体   繁体   中英

Whenever gem error - Could not find command “bin/rails”

I am trying to run a db backup every 3 hours with whenever. The problem is that instead of running I get the following message in the cron logs:

Could not find command "bin/rails".

My schedule.rb file is simple:

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 runs inside a Docker container.

Any idea what might cause this?

Your schedule.rb specifies :bundle_command , so it appears you intend the cronjob to run something using /usr/local/bin/bundle exec ... .

However, :bundle_command is only applicable to job_type :rake or job_type :script . The job_type :runner resolves to something like:

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

Note the above uses bin/rails , not bundle . So chances are, your bin/rails binstub is somehow missing from wherever your :path resolves to. By default the :path resolves to the directory in which whenever was executed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM