• Stars
    star
    138
  • Rank 255,315 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Passenger support for Capistrano 3.x

Capistrano::Passenger

Adds a task to restart your application after deployment via Capistrano. Supports Passenger versions 6 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 :groups.

: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.

Note for rbenv users

If your passenger gem is installed on a different version of Ruby than your :rbenv_ruby Ruby, you can specify this with the following:

set :passenger_environment_variables, { rbenv_version: '3.0.1' }

Note for Standalone Passenger users

If you are running passenger in standalone mode, it is possible for you to put passenger in your Gemfile and rely on capistrano-bundler to install it with the rest of your bundle. If you are installing passenger during your deployment AND you are using the new restart method (see below), you need to set :passenger_in_gemfile to true in your config/deploy.rb.

Restarting Passenger >= 4.0.33 Applications

Passenger 4.0.33 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.0.32 applications.

To opt out of the new way to restart, and use the deprecated approach instead, set :passenger_restart_with_touch to true.

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

More Repositories

1

capistrano

A deployment automation tool built on Ruby, Rake, and SSH.
Ruby
12,631
star
2

sshkit

A toolkit for deploying code and assets to servers in a repeatable, testable, reliable way.
Ruby
1,110
star
3

rails

Official Ruby on Rails specific tasks for Capistrano
Ruby
858
star
4

symfony

Capistrano tasks for deploying the Symfony standard edition
Ruby
354
star
5

laravel

Gem for deploying Laravel projects with capistrano v3.*
Ruby
220
star
6

bundler

Bundler support for Capistrano 3.x
Ruby
219
star
7

rbenv

Idiomatic rbenv support for Capistrano 3.x
Ruby
201
star
8

composer

Capistrano extension for Composer tasks
Ruby
183
star
9

npm

Capistrano extension for npm
Ruby
157
star
10

maintenance

Maintenance Page Support For Capistrano
Ruby
154
star
11

rvm

Ruby
139
star
12

notification-center

Capistrano integration with macOS Notification Center
Ruby
88
star
13

documentation

CSS
81
star
14

file-permissions

File permissions handling for Capistrano v3.*
Ruby
46
star
15

drupal-deploy

Gem for deploying Drupal projects with capistrano 3
Ruby
40
star
16

github

Ruby
26
star
17

capistrano-2.x-docs

An archive of the now-defunct Capistrano 2.x wiki
24
star
18

copy-files

Capistrano v3.* extension for copying files between releases
Ruby
23
star
19

chruby

Ruby
23
star
20

stats

Capistrano statistics, gem, server, manifest and dashboard
Go
12
star
21

packer

Packer manifest to build a debian image for Vagrant which we can use to test against. (and, also for inducting people to the Capistrano way)
Shell
5
star
22

danger

Common Dangerfile for Capistrano projects
Ruby
3
star
23

capistrano-features

A place for discussions about possible Capistrano developments.
2
star
24

capistrano-sprockets

Rails Sprocket Support For Capistrano
2
star