ruby on rails - Could not locate Gemfile or .bundle/ directory ----- rvm | cron | ubuntu | whenever -
i'm using whenever , dynamic_sitemaps gems generate sitemaps.
here's 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' rake "sitemap:generate" end
if use "bundle exec rake sitemap:generate rails_env="production"
" sitemap generated properly.
`bundle exec whenever rails_env="production"` seems working
-
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 schedule file converted cron syntax; crontab file not updated. ## [message] run `whenever --help' more options.
but when check cron.log on day(after 5:30) see message
could not locate gemfile or .bundle/ directory
so, new sitemap wasn't generated. how can fix this?
already tried this solution didn't work me or i'm doing wrong.
i installed ruby rvm
update
so, made working. , here's did:
ls /usr/local/rvm/wrappers/
this gave me list of wrappers/aliases have. 1 of them ruby-2.2.2
then edited 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' rake "sitemap:generate" end
and run bundle exec whenever --update-crontab rails_env="production"
app directory(current).
upd 2017
rvm cron setup
might helpful too
the problem when cron executed, won't load rvm environment. there several approaches solve this. rvm documentation has information need - https://rvm.io/deployment/cron
Comments
Post a Comment