Index: DB/API_REST/daemon_DB.sh |
diff --git a/DB/API_REST/daemon_DB.sh b/DB/API_REST/daemon_DB.sh |
index 4c9ccba65e779e7deece1d97c63045f17cb025b9..3c934a1075c1b1160e0c8d322942f25a00ab8a8f 100644 |
--- a/DB/API_REST/daemon_DB.sh |
+++ b/DB/API_REST/daemon_DB.sh |
@@ -1,25 +1,25 @@ |
#! /bin/sh |
-# Installation |
-# - Move this to /etc/init.d/myservice |
-# - chmod +x this |
-# |
+#The thread which is taking data from the cache and put it into the database is working like a daemon module |
# Starting and stopping |
-# - Start: `service myservice start` or `/etc/init.d/myservice start` |
-# - Stop: `service myservice stop` or `/etc/init.d/myservice stop` |
+# - Start: `service daemon_DB start` |
+# - Stop: `service daemon_DB stop` |
#ref http://till.klampaeckel.de/blog/archives/94-start-stop-daemon,-Gearman-and-a-little-PHP.html |
#ref http://unix.stackexchange.com/questions/85033/use-start-stop-daemon-for-a-php-server/85570#85570 |
#ref http://serverfault.com/questions/229759/launching-a-php-daemon-from-an-lsb-init-script-w-start-stop-daemon |
+#Here we define our damon. Its name, its description, the location of its log and pid. |
NAME=daemon_db |
DESC="Daemon for my magnificent PHP CLI script" |
PIDFILE="/var/run/${NAME}.pid" |
LOGFILE="/var/log/${NAME}.log" |
+#now we define wich program the daemon will run. It will use php7.0 to run the script thread_database.php |
DAEMON="/usr/bin/php7.0" |
DAEMON_OPTS="/var/www/html/API_REST/thread_database.php" |
+#options to start and stop the daemon like a service |
START_OPTS="--start --background --make-pidfile --pidfile ${PIDFILE} --exec ${DAEMON} ${DAEMON_OPTS}" |
STOP_OPTS="--stop --pidfile ${PIDFILE}" |
@@ -27,6 +27,8 @@ test -x $DAEMON || exit 0 |
set -e |
+#usual daemon option (start, stop,restart ...) |
+#store information into its log file |
case "$1" in |
start) |
echo -n "Starting ${DESC}: " |