How can I get passenger-config restart-app to work?
Asked Answered
H

2

6

Rails 4.1 on Ubuntu 14.04 with rbenv and ruby 2.2.1.

Using capistrano with the capistrano-passenger gem, but the restart at the end fails:

INFO [8213c63a] Running /usr/bin/env passenger-config restart-app /home/deployer/my_app --ignore-app-not-running as [email protected]
DEBUG [8213c63a] Command: passenger-config restart-app
DEBUG [8213c63a]    Please pass either an app path prefix or an app group name. See --help for more information.

When I try to run this command at the command line via SSH, I get this:

    deployer@host:~/app/shared/config$ passenger-config restart-app
*** ERROR: You are not authorized to query the status for this

What am I doing wrong here?

I'm using Apache, here's the relevant parts of my /etc/apache2/apache2.conf:

LoadModule passenger_module /home/deployer/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/passenger-5.0.5/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /home/deployer/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/passenger-5.0.5
     PassengerDefaultRuby /home/deployer/.rbenv/versions/2.2.1/bin/ruby
   </IfModule>

<VirtualHost *:80>
      ServerName mysite.name.com
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /home/deployer/myssite/current/public
      <Directory /home/deployer/mysite/current/public>
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
         # Uncomment this if you're on Apache >= 2.4:
         Require all granted
      </Directory>
   </VirtualHost>
Haphazard answered 26/3, 2015 at 17:0 Comment(1)
I just encountered the same issue (Ubuntu 14.04, Apache+mod_passwnger, Rbenv, Ruby 2.0.0p594, Rails 4.1, Capistrano 3.4.0). I am mid-figuring it out right now, but more info from you might help me troubleshoot your setup. Are you using Apache or nginx? If you are using Apache, can you show the DocumentRoot and Passenger* lines from your Apache config?Taps
T
7

Here's what got me running, I added this to my conifg/deploy.rb:

set :passenger_restart_with_sudo, true

Ref: https://github.com/capistrano/passenger/

To add password-less sudo access for the deployer user, on the server do:

(you might want to be more specific as to the allowed commands)

sudo tee /etc/sudoers.d/deployer > /dev/null <<'EOF'
deployer ALL=(ALL) NOPASSWD:ALL
EOF

...and in your delpoy.rb, have:

set :user, 'deployer' # Deployment user on remote servers

Note: it should be noted that the Passenger authors are working on a method so that sudo will not be required any longer in the future.

Taps answered 27/3, 2015 at 19:1 Comment(4)
This didn't help. After adding it, I get: sudo: no tty present and no askpass program specified. So, I added default_run_options[:pty] = true, but it still fails with the same error.Haphazard
I have not been able to get Capistrano to actually work with using sudo passwords. You'll have to use password-less sudo for the deployer user. I kinda really hate that, it makes me feel kinda sick when I think about it. I intend to work on making a fix for this as soon as life gives me time to address it. I'll update my answer with the sudoers line needed.Taps
It should be noted that we (the Passenger authors) are working on a method so that sudo will not be required any longer in the future.Panelboard
Passenger 5.0.10 now has sudo-less restarts with passenger-config. setting :passenger_restart_with_sudo to false should work.Sylviesylvite
O
3

If you don't want to use sudo for restarting application server, simply add to config/deploy.rb:

namespace :deploy do
  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      execute :touch, release_path.join('tmp/restart.txt')
    end
  end
end

For restarting with sudo (Note that it doesn't have any effect on Passenger < 5):

set :passenger_restart_with_sudo, false

If you want to change restarting options, you might override these:

set :passenger_restart_command, 'passenger-config restart-app'
set :passenger_restart_options, -> { "#{deploy_to} --ignore-app-not-running" }
Ose answered 30/3, 2015 at 7:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.