新手问题 passenger 的正确启动方式?怎样才能指向 current 版本?capinstrano 自动启动的方法?

chairy11 · September 09, 2015 · Last by u1446438516 replied at November 02, 2015 · 3426 hits

好吧,我错了…… 又七折腾八折腾,把自己弄晕了……

问题

我用一键部署,以前,基本只需要cap production deploy就万事 OK 了,也不用自己启动 passsenger 的。 但这次,总提示我:There are no Phusion Passenger-served applications running whose paths begin with '/app/www/my_project'. 没法,只好手动启动 passenger 了,用了一句

rvmsudo passenger start -e production -p 80 --user="root"

成功倒是成功了。可以从外网访问了。 但一旦我部署新的版本,它会仍然指向旧的版本,而不是 current

$ passenger-status

Version : 5.0.17
Date    : 2015-09-09 17:35:03 +0800
Instance: H21U8gfz (nginx/1.8.0 Phusion_Passenger/5.0.17)

----------- General information -----------
Max pool size : 6
App groups    : 1
Processes     : 1
Requests in top-level queue : 0

----------- Application groups -----------
/app/www/my_project/releases/20150909024630/public (production):

App root: /app/www/my_project/releases/20150909024630
  Requests in queue: 0
  * PID: 28542   Sessions: 0       Processed: 14      Uptime: 40m 11s
    CPU: 0%      Memory  : 100M    Last used: 17m 14s ago


怎样才能让 passenger 指向 current?

而且我现在也知道怎么 stop,好像用rvmsudo passenger stop不生效,好晕好晕……

注:nginx 配置我是指向了正确位置的

root /app/www/my_project/current/public;
passenger_enabled on;
rails_env production;

hold 不住了……明明以前一键部署很顺利的,现在不知道为什么……是 cap 版本升级了?passenger 版本升级了?还是 nginx 版本升级了?多了很多新的东西?

问题更新

我尝试进 current 目录下手动启动 passenger,它还是具体当前 current 指向的具体版本,下次 current 指向的版本更新,passenger 指向的版本不更新。

如果尝试在项目目录下手动启动 passenger,会显示

$ sudo -E passenger-status
Version : 5.0.17
Date    : 2015-09-10 09:54:12 +0800
Instance: n0pR0FhO (nginx/1.8.0 Phusion_Passenger/5.0.17)

----------- General information -----------
Max pool size : 6
App groups    : 0
Processes     : 0
Requests in top-level queue : 0

----------- Application groups -----------

根本没有指向具体一个 app

capistrano 自动启动 passenger 的机制是怎样的么?以前我都是 cap production deploy 时它自动就启动的啊,现在为什么不启动了?

#1 楼 @fumesy 添加了passenger_app_root /app/www/my_project/current, 还是不行,不知道我错过了什么,或是理解错了什么。

我尝试进 current 目录下手动启动 passenger,它还是具体当前 current 指向的具体版本,下次 current 指向的版本更新,passenger 指向的版本不更新。

如果尝试在项目目录下手动启动 passenger,会显示

$ sudo -E passenger-status
Version : 5.0.17
Date    : 2015-09-10 09:54:12 +0800
Instance: n0pR0FhO (nginx/1.8.0 Phusion_Passenger/5.0.17)

----------- General information -----------
Max pool size : 6
App groups    : 0
Processes     : 0
Requests in top-level queue : 0

----------- Application groups -----------

根本没有指向具体一个 app

没弄明白……

你知道 capistrano 自动启动 passenger 的机制是怎样的么?以前我都是 cap production deploy 时它自动就启动的啊,现在为什么不启动了?

#2 楼 @chairy11 有可能是你的 passenger_ruby配置有问题,如是使用 rvm 还需要做一些改变。 https://www.phusionpassenger.com/library/config/nginx/reference/#passenger_ruby 另外 rvmsudo passenger start -e production -p 80 --user="root" 和 nginx 的 passenger 启动是不同的,一个是standalone,一个是作为 nginx 的插件的形式。

#3 楼 @fumesy 可能的确是 rvm 的缘故,因为我之前一键部署时,都没有用 rvmsudo,一直挺顺利的。 至于这次为什么用,大概是遇到些 bug,然后网上给了答案,就乱用了…… 自己都没搞明白,用不用 rvmsudo 会影响什么…… (到底啥时候用了,啥时候没用,也不记得了……)

passenger_ruby配置是用 passenger 装 nginx 时(passenger-install-nginx-module)自动给配置的啊,应该不会出错吧?

passenger_root /usr/local/rvm/gems/ruby-2.2.3/gems/passenger-5.0.17;
passenger_ruby /usr/local/rvm/gems/ruby-2.2.3/wrappers/ruby;

#3 楼 @fumesy 我是知道我现在是用standalone形式,但我没法换回插件形式。因为如果我单独启动 nginx, 就会显示 passenger 未启动。 怎样才能启动以插件形式启动 passenger? 如果能那样,应该就能回到正常的一键部署的轨道去了……

#5 楼 @chairy11 执行 passenger-config --root passenger-config --ruby-command 把结果写入 passenger_root passenger_ruby ,然后重启 nginx,看是否正常。

#6 楼 @fumesy

我执行这两个命令,得到的结果与我本来在 nginx 中配置的结果是一模一样的,没有任何改动……所以不用重写……

这是执行结果:


$ passenger-config --root
/usr/local/rvm/gems/ruby-2.2.3/gems/passenger-5.0.17
# 这个结果与我之前在nginx配置文件中写的一模一样的


$ passenger-config --ruby-command
passenger-config was invoked through the following Ruby interpreter:
  Command: /usr/local/rvm/gems/ruby-2.2.3/wrappers/ruby
  Version: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
  To use in Apache: PassengerRuby /usr/local/rvm/gems/ruby-2.2.3/wrappers/ruby
  To use in Nginx : passenger_ruby /usr/local/rvm/gems/ruby-2.2.3/wrappers/ruby
  To use with Standalone: /usr/local/rvm/gems/ruby-2.2.3/wrappers/ruby /usr/local/rvm/gems/ruby-2.2.3/gems/passenger-5.0.17/bin/passenger start

# 这个结果也和我之前在nginx配置文件中写的一模一样的

这是我本来的 nginx 配置

passenger_root /usr/local/rvm/gems/ruby-2.2.3/gems/passenger-5.0.17;
passenger_ruby /usr/local/rvm/gems/ruby-2.2.3/wrappers/ruby;

所以还是没解决……

还是非常感谢啊:)

#6 楼 @fumesy 是不是,如果作为插件形式,其实只要开启了 nginx,就会自动启动 passenger? 但如果我直接用

sudo service nginx start

是根本不会启动 passenger 的。 会不会是我 nginx 启动脚本有问题? 我是直接用《Rails 圣经》里的做法:

wget -O init-deb.sh http://www.linode.com/docs/assets/1139-init-deb.sh
   sudo mv init-deb.sh /etc/init.d/nginx
   sudo chmod +x /etc/init.d/nginx
   sudo /usr/sbin/update-rc.d -f nginx defaults

#8 楼 @chairy11 是的,在 nginx 中添加 passenger 的配置就可以了,你可以检查 nginx 的配置是否有问题 sudo nginx -t -c /etc/nginx/nginx.conf # or your config file path

#9 楼 @fumesy

$ sudo nginx -t -c /opt/nginx/conf/nginx.conf

sudo: nginx: command not found

是要检查语法吗?

我用下面这个

$ /opt/nginx/sbin/./nginx  -t 
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/conf/nginx.conf test is successful

结果说语法是 OK 的

@chairy11 检查一下服务器上对应 ruby version 的 gemset 有没有安装 rack gem gem install rack

You need to Sign in before reply, if you don't have an account, please Sign up first.