Skip to content

montdidier/passenger

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Capistrano::Passenger

Adds a task to restart your application after deployment via Capistrano. Supports Passenger versions 5 and lower.

Installation

Add this line to your application's Gemfile:

gem 'capistrano-passenger'

And then execute:

$ bundle

Or install it yourself as:

$ gem install capistrano-passenger

Usage

Add this line to your Capfile and deploy:restart will be setup to automatically run after :publishing is complete:

require 'capistrano/passenger'

You can also run the underlying task in isolation:

# Restart your Passenger application.
# The restart mechanism used is based on the version of Passenger installed on your server.
$ cap production passenger:restart
# Alternatively:
$ cap production deploy:restart

If you want the task to run at a different point in your deployment, require capistrano/passenger/no_hook instead of capistrano/passenger and then add your own hook in config/deploy.rb. When using this gem in this way, you must use passenger:restart--the deploy:restart alias is not available. Example:

# Capfile
require 'capistrano/passenger/no_hook'

# config/deploy.rb
after :some_other_task, :'passenger:restart'

Configurable options and their defaults:

set :passenger_roles, :app
set :passenger_restart_runner, :sequence
set :passenger_restart_wait, 5
set :passenger_restart_limit, 2
set :passenger_restart_with_sudo, false
set :passenger_environment_variables, {}
set :passenger_restart_command, 'passenger-config restart-app'
set :passenger_restart_options, -> { "#{deploy_to} --ignore-app-not-running" }

Restarting Your Passenger Application

In most cases, the default settings should just work for most people. This plugin checks the version of passenger you're running on your server(s) and invokes the appropriate restart mechanism based on that.

passenger_restart_wait and passenger_restart_limit are passed to the on block when restarting the application:

on roles(fetch(:passenger_roles)), in: fetch(:passenger_restart_runner), wait: fetch(:passenger_restart_wait), limit: fetch(:passenger_restart_limit) do
  with fetch(:passenger_environment_variables) do
    # Version-specific restart happens here.
  end
end

Note that passenger_restart_limit has no effect if you are using the default passenger_restart_runner of :sequence. sshkit only looks at it when the runner is :group.

:passenger_environment_variables is available if anything about your environment is not available to the user deploying your application. One use-case for this is when passenger-config isn't available in your user's PATH on the server. You could override it like so:

set :passenger_environment_variables, { :path => '/your/path/to/passenger/bin:$PATH' }

Note for RVM users

https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#_when_the_system_has_multiple_ruby_interpreters descibes how "Once installed, you can run Phusion Passenger’s Ruby parts under any Ruby interpreter you want, even if that Ruby interpreter was not the one you originally installed Phusion Passenger with. [...] There is however one caveat if you happen to be using RVM or RVM gemsets. When you gem install Phusion Passenger using RVM," it is available only to the Ruby version where it was installed. Therefore, if you are using RVM AND passenger was installed via RVM AND it was installed under a different version of RVM than fetch(:rvm_ruby_version), you need to set :passenger_rvm_ruby_version in your config/deploy.rb.

Restarting Passenger 5 (and above) Applications

Passenger 5 introduced a new way to restart your application, and thus has some additional configuration options to accomodate for various server environments.

If you need to pass additional/different options to :passenger_restart_command, simply override :passenger_restart_options.

If you require sudo when restarting passenger, set :passenger_restart_with_sudo to true. Note: This option has no effect when restarting Passenger 4 (and lower) applications.

Contributing

  1. Fork it ( https://github.com/capistrano/passenger/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Passenger support for Capistrano 3.x

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%