Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rhiroyuki/a17cd901c424e6f2f8265d510f932221 to your computer and use it in GitHub Desktop.
Save rhiroyuki/a17cd901c424e6f2f8265d510f932221 to your computer and use it in GitHub Desktop.
running more than one task after deploying with capistrano

If for some reason you want to run more than one task after deploying with capistrano. Create a task that invokes all the tasks you want:

# capistrano/tasks/after_deploy_hooks.rake

namespace :deploy do
  desc 'Deploy hooks'
  task :after_deploy_tasks do
    on roles(:app) do
      within current_path do
        invoke 'service:restart'
        invoke 'sidekiq:restart'
        invoke 'deploy:update_cron'
      end
    end
  end
end

In this task I'm triggering the restart of the webservice, and sidekiq. And running another task to update the crontab. Using invoke will call the task you pass as argument.

And then, inside deploy.rb add the following line at the end of the file.

after :deploy, 'deploy:after_deploy_tasks'

The line above is a hook to run the task after deploy is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment