PHP-PFM is running after /etc/init.d/php5-fpm stop
I really do not understand why PFM daemon is running AFTER my stop.
This is ps aux:
root 998 0.1 0.1 127268 4316 ? Ss 02:13 0:36 /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/main.conf
1004 999 0.0 0.1 127812 4628 ? S 02:13 0:00 /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/main.conf
and this is the /etc/init.d/php5-fpm file
#!/bin/sh
### BEGIN INIT INFO
# Provides: php-fpm php5-fpm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: starts php-fpm开发者_Python百科
### END INIT INFO
set -u
DAEMON="PHP5 FPM"
FPM_CMD=/usr/sbin/php5-fpm
FPM_CONF=/etc/php5/fpm/main.conf
FPM_PID=/var/run/php5-fpm.pid
TIMEOUT=30
FPM_OPTIONS="--fpm-config $FPM_CONF"
SSD_OPTIONS="--oknodo --quiet --pidfile $FPM_PID --exec $FPM_CMD"
. /lib/lsb/init-functions
case "$1" in
start)
log_begin_msg "Starting $DAEMON..."
/sbin/start-stop-daemon --start $SSD_OPTIONS -- $FPM_OPTIONS
log_end_msg $?
;;
stop)
log_begin_msg "Stopping $DAEMON..."
/sbin/start-stop-daemon --stop $SSD_OPTIONS
log_end_msg $?
;;
graceful-stop)
log_begin_msg "Gracefully stopping $DAEMON..."
/sbin/start-stop-daemon --stop --retry QUIT/$TIMEOUT/TERM $SSD_OPTIONS
log_end_msg $?
;;
restart)
$0 stop
$0 start
;;
reload|force-reload)
log_begin_msg "Reloading $DAEMON..."
/sbin/start-stop-daemon --stop --signal USR2 $SSD_OPTIONS
log_end_msg $?
;;
*)
echo "Usage: $0 {start|stop|graceful-stop|restart|reload|force-reload}"
exit 1
;;
esac
What can I do?
Thank you!
I know the post is a bit old by now but still theres a sollution
You can have php-fpm daemonize itself by setting the daemonize=yes in the php-fpm.conf
in the [global] block in the config file you can add or set the pid file for the daemon process by adding this line: pid = /var/run/php-fpm.pid
then just have the start-stop-daemon not set the pid for the php-fpm process but instead use the pid provided by teh daemon itself
the init.d script for php-fpm would look like this then:
#!/bin/sh
NAME="php-fpm"
DESC="${NAME} deamon script"
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
DAEMON="/usr/local/sbin/php-fpm"
DAEMON_OPTS="--fpm-config=/path/to/php-fpm.conf -c=/path/to/php.ini"
#set this file to the same file as in your php-fpm.conf
PIDFILE="/var/run/${NAME}.pid"
QUIET="--quiet"
START_OPTS="--start ${QUIET} --background --exec ${DAEMON} -- ${DAEMON_OPTS}"
STOP_OPTS="--stop --pidfile ${PIDFILE}"
test -x $DAEMON || exit 0
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
export LD_LIBRARY_PATH="/usr/local/lib/"
start-stop-daemon $START_OPTS
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon $STOP_OPTS
echo "$NAME."
;;
restart)
echo -n "Restarting $DESC: "
start-stop-daemon $STOP_OPTS
sleep 1
export LD_LIBRARY_PATH="/usr/local/lib/"
start-stop-daemon $START_OPTS
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
I suggest you do killall -9 php-fpm
and look for php-fpm logs. I suppose it hang processing long php script with set_time_limit(0)
and ignore_user_abort(true)
in it for example.
精彩评论