用 capistrano 一键部署。 我明明是已经装了 passenger 了的。
$ ps aux | grep flying-passenger
deploy 27378 0.0 0.0 13416 936 pts/4 S+ 11:11 0:00 grep --color=auto flying-passenger
$ which passenger-config
/home/deploy/.rvm/gems/ruby-2.2.3/bin/passenger-config
$ cd /home/deploy/.rvm/gems/ruby-2.2.3/gems
$ ls
bundle-0.0.1 bundler-1.10.6 passenger-5.0.16 rack-1.6.4
但部署过程被中断,提示说
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@xxx.xxx.xxx.xxx: passenger exit status: 1
passenger stdout: : Could not find 'passenger' (>= 0) among 14 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/home/deploy/.rvm/gems/ruby-2.2.3:/home/deploy/.rvm/gems/ruby-2.2.3@global',
execute `gem env` for more information
passenger stderr: Nothing written
Tasks: TOP => passenger:restart
(See full trace by running task with --trace)
尝试用
$ passenger start -a 0.0.0.0 -d -e production
无效。
以前出现过其它原因无法启动 passenger 中断情况,我根据教程passenger-config restart-app with capistrano,处理过
# 本机代码修改
# deploy.rb
set :rvm_map_bins, fetch(:rvm_map_bins, []).push('rvmsudo')
set :passenger_restart_command, 'rvmsudo passenger-config restart-app'
但这次不是同样的问题。
不太明白。难道是我 passenger 安装的位置不对吗?
$ gem search passenger
*** REMOTE GEMS ***
balepc-zombie_passenger_killer (0.2.1)
blazing-passenger (0.2.4)
cap_passenger_ping (0.9.0)
capistrano-passenger (0.1.1)
capistrano-passenger5-nginx (0.0.1)
check_passenger (1.0)
cijoe_passenger (0.1.2)
colouringcode-passenger (0.2)
genki-passenger-restart (0.0.2)
guard-passenger (0.6.1)
karsthammer-passenger (2.2.4)
passenger (5.0.16)
passenger-jmazzi (2.2.10)
passenger-oob-gc (0.0.1)
passenger-rails (0.0.2)
passenger-recipes (0.1.2)
passenger_debugger (0.1.3)
passenger_dudemeister (3.0.1)
passenger_dyno (0.0.2)
passenger_mon (0.3.0)
passenger_monit (0.1.1)
passenger_reaper (0.0.2)
passenger_status (0.0.2)
peppyheppy-cpanel-passenger (0.0.3.1)
railsware-passenger (3.0.2.1)
redinger-passenger_debugger (0.1.1)
rockdog-passenger (0.0.1)
ruby-debug-passenger (0.2.0)
yspassenger (3.0.12)
zombie_passenger_killer (0.4.0)
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.8
- RUBY VERSION: 2.2.3 (2015-08-18 patchlevel 173) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/deploy/.rvm/gems/ruby-2.2.3
- RUBY EXECUTABLE: /home/deploy/.rvm/rubies/ruby-2.2.3/bin/ruby
- EXECUTABLE DIRECTORY: /home/deploy/.rvm/gems/ruby-2.2.3/bin
- SPEC CACHE DIRECTORY: /home/deploy/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /home/deploy/.rvm/rubies/ruby-2.2.3/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/deploy/.rvm/gems/ruby-2.2.3
- /home/deploy/.rvm/gems/ruby-2.2.3@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["https://ruby.taobao.org"]
- REMOTE SOURCES:
- https://ruby.taobao.org
- SHELL PATH:
- /home/deploy/.rvm/gems/ruby-2.2.3/bin
- /home/deploy/.rvm/gems/ruby-2.2.3@global/bin
- /home/deploy/.rvm/rubies/ruby-2.2.3/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /home/deploy/.rvm/bin
- /home/deploy/.rvm/bin
能找到的吧?
感觉有点出了问题靠猜
,最终起作用的可能有两个因素,又或是殊途同归。
一是按@ huacnlee 说的把 passenger 加进 gemfile,但一开始没起作用,我就又进服务器项目地址
gem install passenger
passenger start -a 0.0.0.0 -d -e production
这时候再 cap production deploy,又提示我有两个 passenger 实例正在运行,只好又passenger stop
掉一个。
已经用 cap 部署过很多很多项目了,这次问题出得很莫名其妙,难道因为我以前都是在项目目录内 gem install passenger,而这次可能直接在其它目录里? 解决得也有点莫名其妙……
P.S.
因为是节前部署的,后来就忘了。
我想问题很可能出在之前,我忘了进项目目录去gem install passenger
,而是在根目录下安装了。所以 gem 的位置就不对了……
恩,这大概就是基础不扎实的表现……没有意识到在不同路径下装 gem 可能带来不同的结果……