【问题标题】:How can I get passenger-config restart-app to work?如何让乘客配置重启应用程序工作?
【发布时间】:2015-05-30 19:51:51
【问题描述】:

带有 rbenv 和 ruby​​ 2.2.1 的 Ubuntu 14.04 上的 Rails 4.1。

将 capistrano 与 capistrano-passenger gem 一起使用,但最后重启失败:

INFO [8213c63a] Running /usr/bin/env passenger-config restart-app /home/deployer/my_app --ignore-app-not-running as deployer@mysite.com
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.

当我尝试通过 SSH 在命令行运行此命令时,我得到了这个:

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

我在这里做错了什么?

我使用的是 Apache,这是我的 /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>

【问题讨论】:

  • 我刚刚遇到了同样的问题(Ubuntu 14.04、Apache+mod_passwnger、Rbenv、Ruby 2.0.0p594、Rails 4.1、Capistrano 3.4.0)。我现在正在解决这个问题,但您提供的更多信息可能会帮助我解决您的设置问题。你用的是 Apache 还是 nginx?如果您使用的是 Apache,您能否显示 Apache 配置中的 DocumentRoot 和 Passenger* 行?

标签: ruby-on-rails capistrano passenger capistrano3


【解决方案1】:

这就是让我跑步的原因,我将此添加到我的conifg/deploy.rb

set :passenger_restart_with_sudo, true

参考:https://github.com/capistrano/passenger/

要为deployer 用户添加无密码sudo 访问权限,请在服务器上执行以下操作:

(您可能希望更具体地了解允许的命令)

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

...在您的delpoy.rb 中,有:

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

注意:需要注意的是,Passenger 作者以后是working on a method so that sudo will not be required any longer

【讨论】:

  • 这没有帮助。添加后,我得到:sudo: no tty present and no askpass program specified。所以,我添加了default_run_options[:pty] = true,但它仍然失败并出现同样的错误。
  • 我无法让 Capistrano 实际使用 sudo 密码。您必须为部署者用户使用无密码 sudo。我真的很讨厌这样,当我想到它时,我感到有点恶心。一旦生活给了我时间解决这个问题,我打算尽快解决这个问题。我将使用所需的 sudoers 行更新我的答案。
  • 应该注意的是,我们(乘客作者)将来会在 a method so that sudo will not be required any longer 上工作。
  • Passenger 5.0.10 现在使用乘客配置进行无 sudo 重启。将 :passenger_restart_with_sudo 设置为 false 应该可以工作。
【解决方案2】:

如果您不想使用sudo 来重启应用服务器,只需添加到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

使用sudo 重新启动(注意它对Passenger

set :passenger_restart_with_sudo, false

如果您想更改重启选项,您可以覆盖这些:

set :passenger_restart_command, 'passenger-config restart-app'
set :passenger_restart_options, -> { "#{deploy_to} --ignore-app-not-running" }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-03
    • 2015-12-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多