[英]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.