Bonjour,
je travail actuellement sur un serveur de socket écrit en PHP.
Cette partie du travail fonctionne bien. (je l’ai testé avec nohup, pas de problème.)
Cependant j’ai un problème pour le lancer.
En effet, j’ai écrit un script utilisant start-stop-daemon
mais celui-ci ne fonctionne pas.
Pour ce script, je me suis basé sur l’exemple suivant :
http://till.klampaeckel.de/blog/archives/94-start-stop-daemon,-Gearman-and-a-little-PHP.html
Merci d’avance pour votre aide !
#! /bin/sh
### BEGIN INIT INFO
# Provides: ServerTicket
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts ServerTicket
# Description: starts ServerTicket using start-stop-daemon
### END INIT INFO
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/zend/bin/php
DAEMON_OPTS="/var/www/server/consultpilot/ServerTicket.php"
NAME=server-ticket
DESC="Daemon for the Server Ticket from DiffMed"
PIDFILE="/var/run/${NAME}.pid"
LOGFILE="/var/log/${NAME}.log"
QUIET="--quiet"
START_OPTS="--start ${QUIET} --background --make-pidfile --pidfile ${PIDFILE} --exec ${DAEMON} ${DAEMON_OPTS}"
STOP_OPTS="--stop --pidfile ${PIDFILE}"
# START_OPTS="${DAEMON} ${DAEMON_OPTS} &> ${LOGFILE}2>&1&"
# STOP_OPTS="--stop --pidfile ${PIDFILE}"
test -x $DAEMON || exit 0
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon $START_OPTS >> "${LOGFILE}" 2>> "${LOGFILE}" </dev/null
echo "result : ${?}"
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon $STOP_OPTS
echo "$NAME."
rm -f $PIDFILE
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon $STOP_OPTS
sleep 1
start-stop-daemon $START_OPTS
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
Pour information, voilà ce qu’il se passe quand je lance puis stop le script.
Le result 0 correspond a la valeur retournée par le
root:/var/run$ service server-ticket start
Starting Daemon for the Server Ticket from DiffMed: result : 0
server-ticket.
root:/var/run$ service server-ticket stop
Stopping Daemon for the Server Ticket from DiffMed: start-stop-daemon: warning: failed to kill 5772: No such process
1 pids were not killed
No process in pidfile '/var/run/server-ticket.pid' found running; none killed.