Wednesday, May 21, 2008

ruby script/server lighttpd

在一个jruby on rails目录下面运行以下命令时报错:
$> ruby script/server lighttpd
.....
Couldn't find any pid file in '/Users/yu/Sites/RubyOnRails/tmp/pids' matching 'dispatch.[0-9]*.pid'
(also looked for processes matching "/Users/yu/Sites/RubyOnRails/public/dispatch.fcgi")
在lighttpd的log中看到如下信息:
2008-05-21 00:23:33: (log.c.75) server started
2008-05-21 00:23:33: (mod_fastcgi.c.1029) the fastcgi-backend /Users/yu/Sites/RubyOnRails/public/dispatch.fcgi failed to start:
2008-05-21 00:23:33: (mod_fastcgi.c.1033) child exited with status 9 /Users/yu/Sites/RubyOnRails/public/dispatch.fcgi
2008-05-21 00:23:33: (mod_fastcgi.c.1036) If you're trying to run PHP as a FastCGI backend, make sure you're using the FastCGI-enabled version.
You can find out if it is the right one by executing 'php -v' and it should display '(cgi-fcgi)' in the output, NOT '(cgi)' NOR '(cli)'.
For more information, check http://trac.lighttpd.net/trac/wiki/Docs%3AModFastCGI#preparing-php-as-a-fastcgi-programIf this is PHP on Gentoo, add 'fastcgi' to the USE flags.
2008-05-21 00:23:33: (mod_fastcgi.c.1340) [ERROR]: spawning fcgi failed.
2008-05-21 00:23:33: (server.c.908) Configuration of plugins failed. Going down.

经google后才发觉script/server lighttpd只能用于ruby on rails的项目上,通过以下命令:
$> /usr/local/lighttpd/bin/spawn-fcgi -f /Users/yu/Sites/RubyOnRails/public/dispatch.fcgi -p 12000 -s /tmp/rails-fcgi.socket
会得到成功的结果如下:
spawn-fcgi.c.197: child spawned successfully: PID: 2275
而在jruby的项目下调用spawn-fcgi则会报脚本错误。

另附dispatch.sh[reference: http://www.javaeye.com/topic/168989]


#!/bin/sh

DISPATCH_PATH=/Users/yu/Sites/cv2/public/dispatch.fcgi
SOCKET_PATH=//Users/yu/Sites/cv2/tmp/sockets
RAILS_ENV=developement
export RAILS_ENV

case "$1" in

start)
for num in 0 1 2
do
/Users/yu/Programs/lighttpd/bin/spawn-fcgi -f $DISPATCH_PATH -s $SOCKET_PATH/rails.socket-$num
done
;;

stop)
killall -9 dispatch.fcgi
;;

restart)
$0 stop
$0 start
;;

*)
echo "Usage: dispatch.sh {start|stop|restart}"
;;

esac

exit 0

No comments :