Search code examples
ruby-on-railsdeploymentcapistranowheneverwhenever-capistrano

Whenever Cron With Multiple Projects On Server


I use whenever in my rails apps and deploy it with capistrano.

The trouble is that since I use it only for one project there's no problem, but when I use whenever for more projects on the same server, everytime I deploy my project I destroy and recreate the cron file. I need that every project update it or append new instruction, to coexists on the same server.

I simply deploy with

deploy.rb

set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"
...
after "deploy:create_symlink", "deploy:update_crontab"
....

Someone can teach me how can I do?


Solution

  • You'll want to namespace your projects or they'll overwrite each other when you deploy:

    set :whenever_environment, defer { stage }
    set :whenever_identifier, defer { "#{application}_#{stage}" }
    require "whenever/capistrano"