Am Donnerstag, 2. August 2018, 11:32:23 CEST schrieb Alarig Le Lay: > Hi, > > Some times ago, I wrote a basic init script for a service I?m running > but that is not in the tree. > It?s just a python script behind a reverse-proxy. > > bulbizarre ~ # cat /etc/init.d/paste-py > #!/sbin/openrc-run > # Copyright 1999-2015 Gentoo Foundation > # Distributed under the terms of the GNU General Public License v2 > # $Header: $ > > #depend() { > # > #} > > start() { > start-stop-daemon --start --user pastepy --exec paste-py.sh --name > paste-py eend $? > } > > stop() { > kill $(cat /opt/paste-py/paste.pid) > } > bulbizarre ~ # cat $(which paste-py.sh) > #!/bin/sh > > port="$(grep port /opt/paste-py/paste-py.conf | cut -d '=' -f 2)" > addr="$(grep addr /opt/paste-py/paste-py.conf | cut -d '=' -f 2)" > > cd /opt/paste-py > source bin/activate > ./daemonize.py --port=${port} --addr=${addr} > bulbizarre ~ # cat /opt/paste-py/paste.pid > 9480 > bulbizarre ~ # ps aux | grep 9480 > root 493 0.0 0.0 11440 924 pts/3 S+ 11:14 0:00 grep > --colour=auto 9480 pastepy 9480 0.0 0.4 113548 16848 ? S > 08:05 0:00 python ./daemonize.py --port=8087 --addr=127.0.0.1 > > So, the process is running (and responding), but OpenRC shows it as > crashed > > bulbizarre ~ # rc-status | grep crash > paste-py [ > crashed ] > > What do I have to change? > > Thanks,
Hey Alarig, I suggest to read the man-page of start-stop-daemon to get an detailed idea of how it works. You use '--name paste-py' which tells start-stop-daemon to look for a process named 'paste-py' to see if it is still running, when you request the status. As your shell-script runs daemonize.py as the last step and then quits itself, there is no process with the name 'paste-py' and therefore the reported status is 'crashed'. Use '--pidfile /opt/paste-py/paste.pid' instead. With this, the status is determined by reading the pid from the file and then looking if this pid is still running. Greets Manuel