Skip to content

Instantly share code, notes, and snippets.

@pvdb
Created March 13, 2011 10:09
Show Gist options
  • Save pvdb/868002 to your computer and use it in GitHub Desktop.
Save pvdb/868002 to your computer and use it in GitHub Desktop.
Capistrano start/stop/restart tasks for Phusion Passsenger Standalone

With the introduction of Phusion Passenger Standalone, some of the established wisdom with regards to Capistrano tasks for managing Passenger are a tad outdated.

In particular, the start and stop tasks for Passenger are typically NOOPs, and only the restart task is deemed relevant. This is arguably no longer the case for standalone Passenger, where start and stop tasks do make sense, as they did back in the mongrel days.

The following Capistrano tasks illustrate how to start, stop and restart a standalone Passenger setup.

These tasks are for a Passenger setup that uses Unix domain sockets, but they can easily be modified for Passenger instances configured for TCP sockets.

    namespace :deploy do
      task :start, :roles => :app, :except => { :no_release => true } do
        run "cd #{current_path} && bundle exec passenger start --socket /tmp/passenger.socket --daemonize --environment production"
      end
      task :stop, :roles => :app, :except => { :no_release => true } do
        run "cd #{current_path} && bundle exec passenger stop --pid-file tmp/pids/passenger.pid"
      end
      task :restart, :roles => :app, :except => { :no_release => true } do
        run "#{try_sudo} touch #{File.join(current_path, 'tmp', 'restart.txt')}"
      end
    end
@josephholsten
Copy link

This reset task should work fine with a Github Style deploy because it does not require change directories.

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