meta-digi-dey: dey-examples: fix start/stop script of "connectcore-demo-example" service
The start/stop script of the service was using "killproc" and "pidofproc" functions from "/etc/init.d/functions" to find the process PID. These functions rely on "pidof", which does not work very well with Python scripts. Instead, use "pkill" and "pgrep" which allow to search the executable in the full command line to retrieve the correct PID with the -f modifier. Signed-off-by: David Escalona <david.escalona@digi.com>
This commit is contained in:
parent
dda302ef77
commit
bd0eadc16e
|
|
@ -13,17 +13,14 @@
|
|||
#
|
||||
#===============================================================================
|
||||
|
||||
# Source function library
|
||||
. /etc/init.d/functions
|
||||
|
||||
readonly DEMOSERVER_BINARY="/srv/www/demoserver.py"
|
||||
readonly STOP_TIMEOUT="5"
|
||||
|
||||
stop_process() {
|
||||
# try to stop gracefully
|
||||
killproc "${1}" >/dev/null 2>&1
|
||||
pkill -f "${1}" >/dev/null 2>&1
|
||||
for i in $(seq ${STOP_TIMEOUT}); do
|
||||
pid=$(pidofproc "${1}") || break
|
||||
pid=$(pgrep -f "${1}") || break
|
||||
if [ "${i}" -eq ${STOP_TIMEOUT} ]; then
|
||||
kill -KILL "${pid}" >/dev/null 2>&1
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in New Issue