From 5ff89f5317037791e13fe7ff97970c9a35e5f1bc Mon Sep 17 00:00:00 2001 From: StalkR Date: Thu, 7 Sep 2023 10:08:03 +0200 Subject: [PATCH] examples: fix and improve init script - the -c/-f are not read because of "--" and it falls back to the ~/.droppy default - process isn't "droppy" but "@droppyjs/cli" so it doesn't match - use a pidfile instead, more reliable --- examples/droppy.init.d | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/droppy.init.d b/examples/droppy.init.d index be88db9d..4de8245f 100644 --- a/examples/droppy.init.d +++ b/examples/droppy.init.d @@ -10,27 +10,29 @@ # Description: droppy - github.com/droppyjs/droppy ### END INIT INFO -DROPPY_CONFIG_DIR="/srv/droppy/config" -DROPPY_FILES_DIR="/srv/droppy/files" - -PROCESS="droppy" +CONFIG="/srv/droppy/config" +FILES="/srv/droppy/files" +BINARY="/usr/local/bin/droppy" RUNAS="droppy:droppy" -CMD="/usr/bin/env droppy -- start -c '$DROPPY_CONFIG_DIR' -f '$DROPPY_FILES_DIR'" +PIDFILE="/run/droppy.pid" do_start() { - start-stop-daemon --start --background -c $RUNAS --name $PROCESS --exec $CMD + start-stop-daemon --start --background \ + --pidfile "$PIDFILE" --make-pidfile -c "$RUNAS" \ + --exec "$BINARY" -- start -c "$CONFIG" -f "$FILES" } do_stop() { - start-stop-daemon --stop --name $PROCESS + start-stop-daemon --stop --oknodo \ + --pidfile "$PIDFILE" --remove-pidfile -c "$RUNAS" } do_status() { - if pgrep -x "$PROCESS" >/dev/null + if start-stop-daemon --status --pidfile "$PIDFILE" -c "$RUNAS" then - echo "$PROCESS is running" + echo "$BINARY is running" else - echo "$PROCESS stopped" + echo "$BINARY stopped" fi }