同一个主机,之前已经有另一个项目在跑。 现在新增一个项目,监听另一个端口。 在 niginx 里面设置我是这么写的:
server {
listen 8888;
server_name xxx.xxx.xxx.xxx;
passenger_enabled on;
charset utf-8;
root /var/www/a_project/current/public;
rails_env production;
}
server {
listen 9999;
server_name xxx.xxx.xxx.xxx;
charset utf-8;
root /var/www/b_project/current/public;
passenger_enabled on;
rails_env production;
}
现在查看 niginx 是正常监听的, 重启 niginx 之后,niginx 是正常监听的
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN
但我不知道怎么才能重启 passenger
cd /var/www/b_project
touch tmp/restart.txt
会提示:touch: 无法创建"tmp/restart.txt": 没有那个文件或目录
touch tmp/restart.txt
是重启当前项目。
Phusion Passenger checks whether the timestamp of this file has changed in order to determine whether the application should be restarted.
https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html
重启 nginx 用nginx -s reload
#1 楼 @taomaree #2 楼 @flowerwrong 难道意思是,我自己创建一个 tmp/restart.txt就行?这个txt里面什么都不写? (a_project 的时候好像是自动生成的吧,我没创建过,但我一直用touch tmp/restart.txt重启。
#2 楼 @flowerwrong 我是刚把 b_project 弄上去,已经重启了 nginx,但没正常打开,说 something wrong, 所以我觉得应该是没有弄 passenger……
#5 楼 @flowerwrong 看蒙我了 …… 我看了看 nginx 的 error 日志,怀疑是不是因为我上个项目用的是 ruby-2.1.2,这个项目用的是 ruby-2.2.0, (而且我连 rvm 都升级了),然后之前的 passenger 装在 rvm/gems/ruby-2.1.2/gems 里,所以它找不到要用的 passenger……
要不我再装个 passenger 看看……
[ 2015-01-05 02:56:09.7061 29783/7f54445d6700 Pool2/Implementation.cpp:287 ]: Could not spawn process for application /var/www/b_project/current: An error occured while starting up the preloader.
Error ID: 9ad6e2b0
Error details saved to: /tmp/passenger-error-3qukEK.html
Message from application: <p>It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:</p>
<pre class="commands">bundle install</pre>
<p>If that didn't work, then maybe the problem is that your gems are installed to <code>//.rvm/gems</code>, while at the same time you set <code>PassengerRuby</code> (Apache) or <code>passenger_ruby</code> (Nginx) to <code>/usr/local/rvm/gems/ruby-2.1.2/wrappers/ruby</code>. Because of the latter, RVM does not load gems from the home directory.</p>
<p>To make RVM load gems from the home directory, you need to set <code>PassengerRuby</code>/<code>passenger_ruby</code> to an RVM wrapper script inside the home directory:</p>
<ol>
<li>Login as nobody.</li>
<li>Enable RVM mixed mode by running:
<pre class="commands">rvm user gemsets</pre></li>
<li>Run this to find out what to set <code>PassengerRuby</code>/<code>passenger_ruby</code> to:
<pre class="commands">/usr/local/rvm/gems/ruby-2.1.2/wrappers/ruby \
/usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.53/bin/passenger-config --detect-ruby</pre></li>
</ol>
<p>If that didn't help either, then maybe your application is being run under a different environment than it's supposed to. Please check the following:</p>
<ol>
<li>Is this app supposed to be run as the <code>nobody</code> user?</li>
<li>Is this app being run on the correct Ruby interpreter? Below you will
see which Ruby interpreter Phusion Passenger attempted to use.</li>
<li>Please check whether the correct RVM gemset is being used.</li>
<li>Sometimes, RVM gemsets may be broken.
<a href="https://github.com/phusion/passenger/wiki/Resetting-RVM-gemsets">Try resetting them.</a></li>
</ol>
<p>-------- The exception is as follows: -------</p>
Could not find rake-10.4.2 in any of the sources (Bundler::GemNotFound)
<pre> /usr/local/rvm/gems/ruby-2.1.2/gems/bundler-1.7.6/lib/bundler/spec_set.rb:92:in `block in materialize'
/usr/local/rvm/gems/ruby-2.1.2/gems/bundler-1.7.6/lib/bundler/spec_set.rb:85:in `map!'
/usr/local/rvm/gems/ruby-2.1.2/gems/bundler-1.7.6/lib/bundler/spec_set.rb:85:in `materialize'
/usr/local/rvm/gems/ruby-2.1.2/gems/bundler-1.7.6/lib/bundler/definition.rb:132:in `specs'
/usr/local/rvm/gems/ruby-2.1.2/gems/bundler-1.7.6/lib/bundler/definition.rb:177:in `specs_for'
/usr/local/rvm/gems/ruby-2.1.2/gems/bundler-1.7.6/lib/bundler/definition.rb:166:in `requested_specs'
/usr/local/rvm/gems/ruby-2.1.2/gems/bundler-1.7.6/lib/bundler/environment.rb:18:in `requested_specs'
/usr/local/rvm/gems/ruby-2.1.2/gems/bundler-1.7.6/lib/bundler/runtime.rb:13:in `setup'
/usr/local/rvm/gems/ruby-2.1.2/gems/bundler-1.7.6/lib/bundler.rb:121:in `setup'
/usr/local/rvm/gems/ruby-2.1.2/gems/bundler-1.7.6/lib/bundler/setup.rb:17:in `<top (required)>'
/usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
/usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
/usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
/usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.53/lib/phusion_passenger/loader_shared_helpers.rb:263:in `block in run_load_path_setup_code'
/usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.53/lib/phusion_passenger/loader_shared_helpers.rb:366:in `running_bundler'
/usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.53/lib/phusion_passenger/loader_shared_helpers.rb:261:in `run_load_path_setup_code'
/usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.53/helper-scripts/rack-preloader.rb:100:in `preload_app'
/usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.53/helper-scripts/rack-preloader.rb:158:in `<module:App>'
/usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.53/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.53/helper-scripts/rack-preloader.rb:28:in `<main>'</pre>
[ 2015-01-05 02:56:09.7123 29783/7f54421a7700 agents/HelperAgent/RequestHandler.h:2306 ]: [Client 41] Cannot checkout session because a spawning error occurred. The identifier of the error is 9ad6e2b0. Please see earlier logs for details about the error.
在 nginx 的 server 配置使用 passenger_ruby 指定当前 server 对应的 app 使用的 ruby 版本。 Ref: https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#PassengerRuby