Here is a piece of my SysVinit file.
NAME="flask-daemon" PIDFILE="/var/run/"$NAME".pid" DAEMON="/home/ubuntu/flask/run.py" DAEMON_USER=root f_start() { echo -e "\nStarting : $NAME" start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --exec $DAEMON } Does anyone knows where must be the error?
Also, it's terrible that in this situation, it is only writing the PID of ONE process into the pidfile. Therefore, if I do /etc/init.d/flask-daemon stop, it only kills the process which is related with the PID that was considered to be written into the file.
Processes (Why two?):
ps aux | grep run.py root 3591 3.0 1.7 132700 17460 ? S 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py root 3595 4.5 1.7 213144 18080 ? Sl 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py root 3602 0.0 0.0 10460 948 pts/0 S+ 19:27 0:00 grep --color=auto run.py PID file:
$ cat /var/run/flask-daemon.pid 3591 Just one process was killed...
ps aux | grep run.py root 3595 0.3 1.7 213144 18080 ? Sl 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py root 3613 0.0 0.0 10460 948 pts/0 S+ 19:27 0:00 grep --color=auto run.py Observation:> I also tried to use --startas, but it spawns two processes as well, an even worst: it records the PID from any other process into /var/run/flask-daemon.py, with exception of the PIDs from the daemons