From 7c32c040c4c196252ce6c47dc509e89272d7b93e Mon Sep 17 00:00:00 2001 From: f Date: Mon, 2 May 2022 15:42:04 -0300 Subject: [PATCH] remove pidfile correctly --- prometheusd.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/prometheusd.sh b/prometheusd.sh index 47712fc..91e11b1 100755 --- a/prometheusd.sh +++ b/prometheusd.sh @@ -2,11 +2,15 @@ set -e STATS=${STATS:-/tmp/stats.yaml} +pid=/tmp/prometheus.pid case $1 in start) - rm -f /tmp/prometheus.pid - daemonize -c /tmp -p /tmp/prometheus.pid -l /tmp/prometheus.pid -u knot /usr/bin/knot-prometheus-exporter ${STATS} + test -f $tmp && echo "prometheus-exporter already running" + daemonize -c /tmp -p $tmp -l $tmp -u knot /usr/bin/knot-prometheus-exporter ${STATS} + ;; + stop) + test -f $tmp && cat $tmp | xargs -r kill + rm -f $tmp ;; - stop) cat /tmp/prometheus.pid | xargs -r kill ;; esac