When restarting the service - wait until the old proc has been killed before attempting to start it again. Prevents messages about the usuage of kill in the log.

Remove old comment

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
Adam Warner 2022-01-07 22:55:15 +00:00
parent 4cc3587084
commit 9deb685cc0
No known key found for this signature in database
GPG Key ID: 872950F3ECF2B173
2 changed files with 27 additions and 7 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/with-contenv bash
s6-echo "Stopping pihole-FTL"
kill -15 $(pgrep pihole-FTL) # TODO: REVISIT THIS SO AS TO NOT kill -9
kill -15 $(pgrep pihole-FTL)

View File

@ -2,29 +2,49 @@
# This script patches all service commands into the appropriate s6- commands
# pi-hole upstream scripts need a 'service' interface. why not systemd? docker said so.
start() {
s6-svc -wU -u -T2500 /var/run/s6/services/$service
s6-svc -wU -u -T2500 /var/run/s6/services/$service
}
stop() {
s6-svc -wD -d -T2500 /var/run/s6/services/$service
s6-svc -wD -d -T2500 /var/run/s6/services/$service
}
restart() {
local pid
# Get the PID of the service we are asking to restart
pid=$(pgrep $service)
# Only attempt to stop the service if it is already running
if [ -n "$pid" ]; then
stop
# Loop until we are certain that the process has been stopped
while test -d /proc/$pid; do
sleep 0.2
done
fi
# Check it hasn't been started by something else in the meantime
pid=$(pgrep $service)
# Only attempt to start the service if it is not already running
if [ -z "$pid" ]; then
start
#s6-svc -t -wR -T5000 /var/run/s6/services/$service
fi
}
status() {
s6-svstat /var/run/s6/services/$service
s6-svstat /var/run/s6/services/$service
}
service="$1"
command="$2"
if [[ ! -d "/var/run/s6/services/$service" ]] ; then
echo "s6 service not found for $service, exiting..."
exit
echo "s6 service not found for $service, exiting..."
exit
fi;
${command} "${service}"