From e57ec6de50add0993b3933b7fa0f701ea148155c Mon Sep 17 00:00:00 2001 From: Hyperling Date: Tue, 14 Oct 2025 13:47:38 -0700 Subject: [PATCH] Add automatic restart if a primary program is updated. --- cronjob.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/cronjob.sh b/cronjob.sh index 3161841..d82df5e 100755 --- a/cronjob.sh +++ b/cronjob.sh @@ -16,11 +16,14 @@ function log { echo -e "`date` : $NAME - $1" } +function kill-project { + # Kill node.js which will complete run.sh and restart any Docker containers. + log "Stopping continuous processes!" + pkill node +} + function reload-project { - ## Kill node.js which will complete run.sh and restart any Docker containers. - #pkill node - # Do not kill program, just use the new files and if run.sh or main.js were - # changed then they can get reloaded manually or by the nightly backup. + # Nothing to do. log "Project reloaded successfully!" } @@ -35,9 +38,17 @@ grep_status="$?" log "Pull status is '$git_status', checking for changes is '$grep_status'." +echo "$output" | grep "main.js" +main_changed="$?" +echo "$output" | grep "run.sh" +run_changed="$?" + if [[ $git_status != 0 ]]; then log "*** ERROR: Git reported a failure! ***" exit 1 +elif [[ $git_status == 0 && ($main_changed == 0 || $run_changed == 0) ]]; then + log "Either main ('$main_changed'), or run ('$run_changed') were changed!" + kill-project elif [[ $git_status == 0 && $grep_status == 0 ]]; then reload-project elif [[ $git_status == 0 && $grep_status != 0 ]]; then