railsmachine / moonshine

Simple Rails deployment and configuration management. 15 minute deploys of Rails 2, 3, or 4 apps.
http://railsmachine.github.com/moonshine/
GNU Lesser General Public License v3.0
666 stars 70 forks source link

Adds support for Passenger 5. #240

Closed bryantraywick closed 9 years ago

jarinudom commented 9 years ago

Oh nice, thanks! Hopefully this fixes the problem with it reinstalling Passenger on every deploy :)

bryantraywick commented 9 years ago

@jarinudom Yes this does fix the problem with Passenger reinstalling on every deploy. Passenger 5 changed the location of some of the native build artifacts so the the apache module compilation task was being run every deploy. I updated the conditional so that it performs the proper check for Passenger 5. The default version is still Passenger 4 but that will likely change shortly once we've had more experience with Passenger 5 and are sure it's not going to cause unexpected problems.

There is a new setting, :passenger => :stat_throttle_rate, for Passenger 5. The default is 10 (as in 10 seconds) which is the same default in Passenger 5. This setting controls how often Passenger checks if tmp/restart.txt has been touched. The previous behavior, which can be achieved by setting :stat_throttle_rate to 0, was to check every request. This adds an "expensive" overhead on every request so the default of every 10 seconds was decided on by Phusion. This means that the app won't be reloaded until 10 seconds after the deploy completes. The recommended way to get around this delay is to instead call sudo passenger-config restart-app at the end of the deploy instead of touching tmp/restart.txt. This triggers an immediate restart without the overhead of checking tmp/restart.txt on each request.

To restart the app with capistrano 2 add the following to your config/deploy.rb file:

namespace :deploy do
  task :restart, :roles => :app, :except => { :no_release => true } do
    sudo "passenger-config restart-app --ignore-app-not-running /srv/<your-app-name-here>/current"
  end
end

Be sure to replace <your-app-name-here> to your application's name or /srv/app-name/current to the app's location if you have it deployed somewhere other than /srv (e.g /var/www/apps/app-name/current).