Hi Ondřej, On Fri, May 31, 2013 at 11:44:53PM +0200, Ondřej Surý wrote: > I have tried to rewrite php5-fpm init.d file for systemd and upstart and > ended up with:
> cat > php5-fpm.service << EOF > [Unit] > Description=The PHP FastCGI Process Manager > After=syslog.target network.target > [Service] > Type=forking > PIDFile=/var/run/php5-fpm.pid > ExecStartPre=sh -c 'if [ -n "$(/usr/sbin/php5-fpm --fpm-config > /etc/php5/fpm/php-fpm.conf -t 2>&1 | grep "\[ERROR\]")" ]; then echo > "Please fix your configuration file..."; /usr/sbin/php5-fpm --f\ > pm-config /etc/php5/fpm/php-fpm.conf -t 2>&1 | grep "\[ERROR\]"; exit 1; fi' > ExecStart=/usr/sbin/php5-fpm > ExecReload=/bin/kill -USR2 $MAINPID > [Install] > WantedBy=multi-user.target > EOF > and > cat > php5-fpm.upstart << EOF > # php5-fpm - The PHP FastCGI Process Manager > description "The PHP FastCGI Process Manager" > author "Ondřej Surý <ond...@debian.org>" > start on (local-filesystems and net-device-up IFACE!=lo) > stop on runlevel [016] FYI, it's strongly recommended to use 'start on runlevel [2345]' here as the start condition, for several reasons: - The 'filesystem' events are one-time events seen only at boot time; if the admin drops the system to runlevel 1 and then returns to runlevel 2, you probably want the service to restart. - The event name is 'local-filesystem', not 'local-filesystems', so this job wouldn't auto-start at all. (FWIW, the 'initctl check-config' command from the upstart package would warn about this; but this tool is only usable when upstart is the running init, so probably not ideal for packagers not running upstart themselves.) - The 'local-filesystem' event may be emitted before any remote filesystems have been mounted... which might include part or all of /usr and /var. So since php5-fpm is itself not a service that is used for mounting remote filesystems, it should not try to start until the filesystem is completely up. The 'runlevel' event is later than both the 'local-filesystem' event and the 'net-device-up' events, except in the case where your network interface is configured with network-manager instead of ifupdown. So you shouldn't need to worry about this causing your service to start too "early". > pre-start script > if [ -n "$(/usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/php-fpm.conf -t > 2>&1 | grep "\[ERROR\]")" ]; then > echo "Please fix your configuration file..." > /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/php-fpm.conf -t 2>&1 | > grep "\[ERROR\]" > stop ; exit 1 > fi > end script Unrelated style comment - you could write this to call php5-fpm -t a single time: pre-start script errors=$(/usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/php-fpm.conf -t 2>&1 | grep "\[ERROR\]") if [ -n "$errors" ]; then echo "Please fix your configuration file..." echo $errors stop ; exit 1 fi end script Also, the 'exit 1' is unnecessary; the 'stop' is sufficient to ensure the job stops, all the 'exit 1' does is result in additional log spam. > respawn > exec /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/php-fpm.conf > EOF > It's pretty much equivalent with one exception – I need to send USR2 on > reload. Does upstart already have the support for custom reload signals? Presently not, as Clint mentions - though I see Dmitrijs has just claimed https://bugs.launchpad.net/upstart/+bug/893021 for himself in response to this thread. :) -- Steve Langasek Give me a lever long enough and a Free OS Debian Developer to set it on, and I can move the world. Ubuntu Developer http://www.debian.org/ slanga...@ubuntu.com vor...@debian.org
signature.asc
Description: Digital signature