Use a parent process checker for both forked jobs.

This commit is contained in:
2025-10-14 11:43:03 -07:00
parent 6def1a3007
commit 1fa30724d2

18
run.sh
View File

@@ -27,6 +27,20 @@ function log {
echo -e "`date` - $message" 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 ## ## Parameters ##
while getopts ':p:h' opt; do while getopts ':p:h' opt; do
@@ -96,6 +110,7 @@ npm install
log "Removing old index files." log "Removing old index files."
find files/photos/ -name "*".html -print -delete find files/photos/ -name "*".html -print -delete
{ {
check_main photos
count=1 count=1
http_code=0 http_code=0
port="${ports%% *}" port="${ports%% *}"
@@ -121,8 +136,9 @@ find files/photos/ -name "*".html -print -delete
## Main ## ## Main ##
log "Start repo updater" log "Start repo updater."
while true; do while true; do
check_main cronjob
$DIR/cronjob.sh $DIR/cronjob.sh
sleep 30 sleep 30
done & done &