Actions
HowToRestartLocalBackendWithoutDowntime » History » Revision 1
Revision 1/3
| Next »
Anonymous, 2007-01-30 00:07
{{{
Restarting FCGI backend without downtime.
In case you have FCGI backend running on local sockets, it's possible to restart FCGI backend so that lighty never sees backend being down.
In short it's that we start backend on temporary socket and when started we rename the socket and then kill the old backend service.
- config
PHP_FCGI_CHILDREN=5
SPAWN_SOCKET="/var/run/php/fcgi.sock"
PHP_FCGI_BINARY=/usr/bin/php.fcgi
- start new instance
socket="$SPAWN_SOCKET"
pid=$(cat /var/run/php-fcgi.pid)
SPAWN_SOCKET=$(mktemp -p ${SPAWN_SOCKET%/*} ${SPAWN_SOCKET##*/}.XXXXXX) || exit 1
spawn-fcgi -P /var/run/php-fcgi.pid -f $PHP_FCGI_BINARY -s $SPAWN_SOCKET -C $PHP_FCGI_CHILDREN || exit 1 - optional
chown lighttpd $SPAWN_SOCKET
chgrp lighttpd $SPAWN_SOCKET - let lighty use new socket
mv -f "$SPAWN_SOCKET" "$socket"
- sleep to let old requests to finish
sleep 10
- now can stop old instance
kill $pid
}}}
Updated by Anonymous almost 18 years ago · 1 revisions