Skip to content

Instantly share code, notes, and snippets.

@pvdb
Created March 13, 2011 10:09
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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
@fabn
Copy link

fabn commented Mar 20, 2011

I found this thread on passenger google group, from what it says your restart task isn't going to work, because if you don't restart your app the process working directory doesn't change. What do you think about that?

@ciastek
Copy link

ciastek commented Jul 6, 2012

When you use bundled Passenger Standalone using bundle exec passenger touching tmp/restart.txt doesn't restart application properly. Especially your application won't see new, freshly bundled gems. You need to restart Passenger by stopping and starting.

@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