ようやくわかった
passenger_ruby /home/USER/.rbnev/versions/1.9.3-p0/bin/ruby;
を
passenger_ruby /home/USER/.rbnev/shims/ruby;
としていたため。とりあえずベタ書きで対応。
稼動しているサーバから持ってきた設定であったが、
おそらく以下のようなdot-file設定等々に影響してるのだろうな、と。
export PATH=”$HOME/.rbenv/bin:$PATH”
eval “$(rbenv init -)”
source ~/.rbenv/completions/rbenv.bash
今気がついて、まだ直せていない
/etc/init.d/nginx で起動すると
/home/USER/.rbenv/shims/ruby: line 4: exec: rbenv: not found
がnginxのerror_logに出続けるので修正する
例えば http://exmaple.com/ にアクセスするとして
Cannot spawn application ‘/path/to/rails_root’: Could not read from the spawn server: Connection reset by peer (104)
というエラーがでる
/usr/local/nginx/sbin/nginx も /etc/init.d.nginx start も
期待通りの挙動を示していないため、passengerとの連携に問題があると言えそう。
WEBRICK単独ではsinatraさんは期待通りに動いてくれている。
最初の小細工
# yum install nginx# cp -a /etc/init.d/nginx /bkup/path/to/# yum remove nginx# cp -a /bkup/path/to/nginx{,.yum-org}# vim /bkup/path/to/nginx
config option(*1)
#https://gist.github.com/1712762./configure \--prefix=/usr/local/nginx \--conf-path=/etc/nginx/nginx.conf \--error-log-path=/var/log/nginx/error.log \--pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/subsys/nginx \--user=nginx \--group=nginx \--with-http_stub_status_module \--with-http_ssl_module \--with-http_gzip_static_module \--with-http_realip_module \--http-log-path=/var/log/nginx/access.log \--http-client-body-temp-path=/var/tmp/nginx/client/ \--http-proxy-temp-path=/var/tmp/nginx/proxy/ \--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \--with-cc-opt='-Wno-error' \--add-module='/home/USER/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/ext/nginx' \&& make
yum 版 nginx との差分
--- nginx.yum-org 2011-12-16 00:22:28.000000000 +0900+++ nginx 2012-02-01 04:10:39.447206296 +0900@@ -6,7 +6,7 @@ # processname: nginx # config: /etc/nginx/nginx.conf # config: /etc/sysconfig/nginx-# pidfile: /var/run/nginx.pid+# pidfile: /var/run/nginx/nginx.pid # description: nginx is a HTTP and reverse proxy server # ### BEGIN INIT INFO@@ -28,10 +28,10 @@ fi prog=nginx-nginx=${NGINX-/usr/sbin/nginx}+nginx=${NGINX-/usr/local/nginx/sbin/nginx} conffile=${CONFFILE-/etc/nginx/nginx.conf} lockfile=${LOCKFILE-/var/lock/subsys/nginx}-pidfile=${PIDFILE-/var/run/nginx.pid}+pidfile=${PIDFILE-/var/run/nginx/nginx.pid} SLEEPMSEC=100000 RETVAL=0
修正後の nginx 起動スクリプト
#!/bin/sh## nginx Startup script for nginx## chkconfig: - 85 15# processname: nginx# config: /etc/nginx/nginx.conf# config: /etc/sysconfig/nginx# pidfile: /var/run/nginx/nginx.pid# description: nginx is a HTTP and reverse proxy server#### BEGIN INIT INFO# Provides: nginx# Required-Start: $local_fs $remote_fs $network# Required-Stop: $local_fs $remote_fs $network# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: start and stop nginx### END INIT INFO
# Source function library.. /etc/rc.d/init.d/functions
CONFFILE="/etc/nginx/nginx.conf"
if [ -f /etc/sysconfig/nginx ]; then . /etc/sysconfig/nginxfi
prog=nginxnginx=${NGINX-/usr/local/nginx/sbin/nginx}conffile=${CONFFILE-/etc/nginx/nginx.conf}lockfile=${LOCKFILE-/var/lock/subsys/nginx}pidfile=${PIDFILE-/var/run/nginx/nginx.pid}SLEEPMSEC=100000RETVAL=0
start() { echo -n $"Starting $prog: "
daemon --pidfile=${pidfile} ${nginx} -c ${conffile} RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL}
stop() { echo -n $"Stopping $prog: " killproc -p ${pidfile} ${prog} RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}}
reload() { echo -n $"Reloading $prog: " killproc -p ${pidfile} ${prog} -HUP RETVAL=$? echo}
upgrade() { oldbinpidfile=${pidfile}.oldbin
configtest -q || return 6 echo -n $"Staring new master $prog: " killproc -p ${pidfile} ${prog} -USR2 RETVAL=$? echo /bin/usleep $SLEEPMSEC if [ -f ${oldbinpidfile} -a -f ${pidfile} ]; then echo -n $"Graceful shutdown of old $prog: " killproc -p ${oldbinpidfile} ${prog} -QUIT RETVAL=$? echo else echo $"Upgrade failed!" return 1 fi}
configtest() { if [ "$#" -ne 0 ] ; then case "$1" in -q) FLAG=$1 ;; *) ;; esac shift fi ${nginx} -t -c ${conffile} $FLAG RETVAL=$? return $RETVAL}
rh_status() { status -p ${pidfile} ${nginx}}
# See how we were called.case "$1" in start) rh_status >/dev/null 2>&1 && exit 0 start ;; stop) stop ;; status) rh_status RETVAL=$? ;; restart) configtest -q || exit $RETVAL stop start ;; upgrade) upgrade ;; condrestart|try-restart) if rh_status >/dev/null 2>&1; then stop start fi ;; force-reload|reload) reload ;; configtest) configtest ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest}" RETVAL=2esac
exit $RETVAL
*1: –lock-path を以前のものから変更した