[英]Could not locate Gemfile or .bundle/ directory --— rvm | cron | ubuntu | whenever
我正在使用everything和dynamic_sitemaps寶石來生成站點地圖。
這是我的schedule.rb
job_type :rake, "{ cd #{@current_path} > /dev/null; } && RAILS_ENV=:environment bundle exec rake :task --silent :output"
job_type :script, "{ cd #{@current_path} > /dev/null; } && RAILS_ENV=:environment bundle exec script/:task :output"
job_type :runner, "{ cd #{@current_path} > /dev/null; } && RAILS_ENV=:environment bundle exec rails runner ':task' :output"
set :output, "#{path}/log/cron.log"
every 1.day, :at => '5:30 am' do
rake "sitemap:generate"
end
如果我使用“ bundle exec rake sitemap:generate RAILS_ENV="production"
“,則我的站點地圖會正確生成。
`bundle exec whenever RAILS_ENV="production"` seems to be working too
-
30 5 * * * /bin/bash -l -c '{ cd > /dev/null; } && RAILS_ENV=production bundle exec rake sitemap:generate --silent >> /var/www/.*******.log 2>&1'
## [message] Above is your schedule file converted to cron syntax; your crontab file was not updated.
## [message] Run `whenever --help' for more options.
但是當我在另一天(5:30之后)檢查cron.log時,我看到此消息
Could not locate Gemfile or .bundle/ directory
因此,沒有生成新的站點地圖。 我怎樣才能解決這個問題?
已經嘗試過此解決方案,但對我不起作用,或者我做錯了什么。
我用rvm安裝了ruby
UPDATE
所以,我讓它工作了。 這就是我所做的:
ls /usr/local/rvm/wrappers/
這給了我一個包裝器/別名的列表。 其中之一是ruby-2.2.2
然后我編輯了schedule.rb
set :output, "#{path}/log/cron.log"
job_type :runner, "cd #{path} && RAILS_ENV=production /home/$USER/.rvm/wrappers/ruby-2.2.2/bundle exec rails runner ':task' :output"
every 1.day, :at => '4:30 am' do
rake "sitemap:generate"
end
並在應用目錄(當前)中的bundle exec whenever --update-crontab RAILS_ENV="production"
運行bundle exec whenever --update-crontab RAILS_ENV="production"
。
UPD 2017
rvm cron setup
可能也有幫助
問題是執行cron時,它不會加載rvm環境。 有幾種解決方法。 該RVM文檔有你需要的所有信息- https://rvm.io/deployment/cron
由於@current_path
為nil,因此將目錄更改為home( cd > /dev/null;
)。
如果刪除前三行,它應該可以工作。 ( https://github.com/javan/whenever/blob/master/lib/whenever/setup.rb )
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.