54 lines
1.3 KiB
Bash
54 lines
1.3 KiB
Bash
#!/bin/sh
|
|
#
|
|
# /etc/init.d/lighten-mailbox
|
|
# Fichier sous-système pour le serveur "lighten-mailbox"
|
|
|
|
###### Configure THIS !!
|
|
# Chemin de l'application :
|
|
DIR="/var/www/lighten-mailbox.zici.fr/web"
|
|
# Utilisateur qui lance le daemon (le même qui exécute php sur votre serveur web, souvent www-data)
|
|
USER="web242"
|
|
#USER="www-data"
|
|
|
|
NAME=lighten-mailbox
|
|
DESC="Daemon PHP CLI script"
|
|
PIDFILE="/var/run/${NAME}.pid"
|
|
LOGFILE="/var/log/${NAME}.log"
|
|
|
|
DAEMON="/usr/bin/php ${DIR}/daemon.php"
|
|
DAEMON_OPTS="-d ${DIR}"
|
|
|
|
START_OPTS="--start --background --chuid ${USER} --make-pidfile --pidfile ${PIDFILE} --exec ${DAEMON} ${DAEMON_OPTS}"
|
|
STOP_OPTS="--stop --pidfile ${PIDFILE}"
|
|
|
|
set -e
|
|
|
|
# https://mk57blog.wordpress.com/2017/01/30/executer-un-script-php-comme-daemon/
|
|
|
|
case "$1" in
|
|
start)
|
|
echo -n "Starting ${DESC}: "
|
|
start-stop-daemon $START_OPTS >> $LOGFILE
|
|
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 >> $LOGFILE
|
|
echo "$NAME."
|
|
;;
|
|
*)
|
|
N=/etc/init.d/$NAME
|
|
echo "Usage: $N {start|stop|restart|force-reload}" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit 0
|