Capistrano and Passenger

To use Capistrano on a Passenger enabled host, you need to add the following lines to your config/deploy.rb file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
namespace :deploy do
  desc "Restarting mod_rails with restart.txt"
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{current_path}/tmp/restart.txt"
  end

  desc "Stop task is a deploy.web.disable with mod_rails"
  task :stop, :roles => :app do
    deploy.web.disable
  end

  desc "Start task is a deploy.web.enable with mod_rails"
  task :start, :roles => :app do
    deploy.web.enable
  end
end

Because in passenger there is no way of stopping or starting your Rails application, I’ve changed the deploy:start and deploy:stop to deploy:web:enable and deploy:web:disable. The deploy:restart is used by the deploy task, so now your deployment works as expected.

Update: Don’t forget to add the rewrite rules to your apache virtual host config, otherwise the enable disable tasks won’t work.

1
2
3
4
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]

Comments

Copyright © 2013 - Tom Pesman - Powered by Octopress