]> Sergey Matveev's repositories - sgmon.git/commitdiff
Get rid of pid file outside state directory
authorSergey Matveev <stargrave@stargrave.org>
Tue, 29 Mar 2022 15:36:49 +0000 (18:36 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 29 Mar 2022 15:45:25 +0000 (18:45 +0300)
README
clear.sh
start.sh

diff --git a/README b/README
index 87ad8dc91772a53c38a7c3783ceeaacf4b9ddf90..965731349efcfe61892c6d40508dec01bc87252d 100644 (file)
--- a/README
+++ b/README
@@ -48,11 +48,11 @@ It is advisable to run it under daemontools'es supervise utility for
 convenience.
 
 run.sh creates temporary directory for each probe and links it to
-$probe/state. Also $probe/pid file is created there. run-script expects
-that it is run from the $probe directory, there is state/, where it can
-store its temporary files. $SGMONDIR are also always set $SGMONSRV.
+$probe/state. run-script expects that it is run from the $probe
+directory, there is state/, where it can store its temporary files.
+$SGMONDIR and $SGMONDIR are also always set too.
 
-You can remove all pid-files and state/-directories with clear.sh.
+You can remove all state directories with clear.sh.
 
 Generate HTML page with information about state of all services and
 their output:
index 38ad620673c479013bb83d0472fef3ef887d9cbe..18fbae5912793a3a65b6be09bf469e6ac1a94701 100755 (executable)
--- a/clear.sh
+++ b/clear.sh
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-find . \( -name state -or -name -pid \) -delete -print
+find . -name state -delete -print
index 30315ddd28040e6816eabff11ad5a1a48787bcb0..7d4baa61913323ef63971cda07f2605c618b6a90 100755 (executable)
--- a/start.sh
+++ b/start.sh
@@ -4,14 +4,14 @@ stop() {
     trap - HUP PIPE INT QUIT TERM EXIT
     echo ... | mailx -s "Stopping" "$NOTIFY_EMAIL"
     for probe in $probes ; do
-        [ -s $probe/pid ] || continue
-        echo killing ${probe}...
-        pkill -F $probe/pid 2>/dev/null || :
+        [ -s $probe/state/pid ] || continue
+        echo killing ${probe}
+        pkill -F $probe/state/pid 2>/dev/null || :
     done
     for probe in $probes ; do
-        read pid < $probe/pid || :
+        read pid < $probe/state/pid || :
         [ -n "$pid" ] || continue
-        echo waiting ${probe}...
+        echo waiting ${probe}
         wait $pid || :
     done
     echo finished
@@ -25,9 +25,19 @@ probes="$("$SGMONDIR"/probelist.sh)"
 echo $(echo "$probes" | wc -l) probes | mailx -s "Starting" "$NOTIFY_EMAIL"
 for probe in $probes ; do
     cd $probe
-    echo starting ${probe}...
+    echo -n starting ${probe}
     "$SGMONDIR"/run.sh $probe >/dev/null 2>&1 &
-    echo $! > pid || :
+    pid=$!
+    while : ; do
+        if  [ -d state ] ; then
+            break
+        else
+            sleep 1
+            echo -n .
+        fi
+    done
+    echo ""
+    echo $pid > state/pid || :
     cd "$root"
 done
 echo OK