Created
May 15, 2015 11:24
-
-
Save attilahorvath/8634656bae76ea191b78 to your computer and use it in GitHub Desktop.
Whenever tasks to automatically start web apps and background workers after a server reboot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/deploy.rb | |
# Using Capistrano 3 | |
# Set the current environment for Whenever and avoid name collisions | |
set :whenever_environment, -> { fetch(:stage) } | |
set :whenever_identifier, -> { "#{fetch(:application)}_#{fetch(:stage)}" } | |
# config/schedule.rb | |
every "@reboot" do | |
# If the app is using Puma | |
command "cd #{path} && bundle exec puma -e #{@environment}" | |
# If the app is using Delayed Job | |
command "cd #{path} && RAILS_ENV=#{@environment} bundle exec delayed_job start" | |
# If the app is using Sidekiq | |
command "cd #{path} && RAILS_ENV=#{@environment} bundle exec sidekiq" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment