How can I use deployment callbacks?

As with Capistrano, you can add custom deployment hooks to your application's code base. They'll be run according to the state of the deployment. The available hooks are

  • before migrate
  • before symlink
  • before restart
  • after restart

For each hook you want to use, you need a file named after the hook (e.g. after_restart.rb) in your deploy/ directory in your application's code base. For an example, check out our tiny example application for an example.

The deployment is based on Chef's deployment resource, and the code in your hooks is run in its context, so you can access the common variables like release_path, current_path and the like.

If you use Bundler for example, your before_migrate hook could look like this:

$ cat deploy/before_migrate.rb

run "cd #{release_path} && bundle install"

Deployment hooks allow you to customize the deployment. If you want to customize the setup of the instance, have a look at how to customize instance setup using Chef cookbooks.

TODO: Add more information on the available variables and things like running commands