From 1fa30724d25384318b785aafe83b8659b887b672 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Tue, 14 Oct 2025 11:43:03 -0700 Subject: [PATCH] Use a parent process checker for both forked jobs. --- run.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 5bfed1c..4d25526 100755 --- a/run.sh +++ b/run.sh @@ -27,6 +27,20 @@ function log { echo -e "`date` - $message" } +function check_main { + if [[ -z "$1" ]]; then + echo "ERROR: Subprocess name was not provided. $1" + exit 0 + fi + log "Subprocess '$1' checking if main process is still running..." + ps $$ + status=$? + if [[ $status != 0 ]]; then + log "Process '$$' not found, '$1' from '$DIR/$PROG' exiting." + exit 0 + fi +} + ## Parameters ## while getopts ':p:h' opt; do @@ -96,6 +110,7 @@ npm install log "Removing old index files." find files/photos/ -name "*".html -print -delete { + check_main photos count=1 http_code=0 port="${ports%% *}" @@ -121,8 +136,9 @@ find files/photos/ -name "*".html -print -delete ## Main ## -log "Start repo updater" +log "Start repo updater." while true; do + check_main cronjob $DIR/cronjob.sh sleep 30 done &