Friends,

I've got an interesting issue with a few catalyst apps. I have a server running two apps under apache with FastCGI. I wrote an init script to start and stop the app server, it's attached below. I started having issues with the init script once I began running multiple apps. The init scripts ( using the standard rc.d/functions library ) identify the PID of the FastCGI process via it's process name, which is "perl-fcgi-pm". Because of this, when I issue a stop or restart command to the catalyst server via the init script, it may operate on the wrong process.

I dug into trying to change the running process name as seen by ps, but this seems to be a fully static value defined by FCGI::ProcManager with no option to override it (?).

I tried to get the init script able to properly identify the processes ( it seems to use the PID files which contain the correct PID for each process ) but it still might operate on the incorrect PID.

I've seen it mentioned on the list to use daemon tools with PAR ( http://www.catalystframework.org/calendar/2006/4 ) but that uses the built-in myapp_server.pl, running it's own web server, and I much prefer the apache/fastcgi approach, most especially because it leaves the work of serving static content to apache instead of the heavier application process.

Does anybody have a better init script than the one below for handling the fastcgi processes? I'm probably missing something obvious X.X

Kind Regards,

/Mitchell Jackson
OnSite Mobile

___________________________
#!/bin/bash
#
# qualify        manage qualify fastcgi server
#
# chkconfig: - 89 16
# description: Manage starting, stopping and restarting the \
#              catalyst fastcgi application
# processname: qualify
# pidfile: /var/run/qualify_fastcgi.pid

# Source function library
. /etc/rc.d/init.d/functions

# Paths
fastcgi=/var/www/qualify.x.com/qualify/script/qualify_fastcgi.pl
socket=/tmp/qualify.socket
prog=perl-fcgi-pm
pidfile=${PIDFILE-/tmp/qualify_fastcgi.pid}
lockfile=${LOCKFILE-/var/lock/qualify_fastcgi}
RETVAL=0
userid=qualify.x.com
parms=$"-l $socket -n 5 -p $pidfile -d"

start() {
       echo -n $"Starting $prog: "
       daemon --user $userid --pidfile $pidfile $fastcgi $parms
       RETVAL=$?
       echo
       [ $RETVAL = 0 ] && touch ${lockfile}
       return $RETVAL
}
stop() {
       echo -n $"Stopping $prog: "
       killproc -p $pidfile -d 10 $prog
       RETVAL=$?
       echo
       [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}

# See how we were called.
case "$1" in
 start)
       start
       ;;
 stop)
       stop
       ;;
 status)
       status -p $pidfile $prog
       RETVAL=$?
       ;;
 restart)
       stop
       start
       ;;
 condrestart)
       if [ -f ${pidfile} ] ; then
               stop
               start
       fi
       ;;
 *)
       echo $"Usage: $prog {start|stop|restart|condrestart|status|help}"
       exit 1
esac

exit $RETVAL


_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Reply via email to