If I run my script manually, i.e. sh /home/deploy/scripts/cleanup.sh
, everything works fine, but when executing the same script via crontab, the delayed_job part does not work (everything else works!)
# Restart all processes
cd ~/apps/kosher/current
~/.rvm/bin/rvm default do bundle exec pumactl -S /home/deploy/apps/kosher/shared/tmp/pids/puma.state -F /home/deploy/apps/kosher/shared/puma.rb stop
~/.rvm/bin/rvm default do bundle exec puma -C /home/deploy/apps/kosher/shared/puma.rb --daemon
if RAILS_ENV=production bin/delayed_job restart
then
echo "kosher delayed_job restarted" >> /home/deploy/scripts/cleanup.log
else
echo "kosher delayed_job restart failed" >> /home/deploy/scripts/cleanup.log
fi
I tried to use ~/.rvm/bin/rvm default do bundle exec bin/delayed_job -n 1 restart
instead of RAILS_ENV=production bin/delayed_job restart
, but then I receive an error, stating, that I'm missing the listen-gem:
bundler: failed to load command: bin/delayed_job (bin/delayed_job)
LoadError: Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile
However, my Gemfile does indeed include the gem.
Why can't I restart delayed_job via crontab?