Add automatic restart if a primary program is updated.
This commit is contained in:
19
cronjob.sh
19
cronjob.sh
@@ -16,11 +16,14 @@ function log {
|
|||||||
echo -e "`date` : $NAME - $1"
|
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 {
|
function reload-project {
|
||||||
## Kill node.js which will complete run.sh and restart any Docker containers.
|
# Nothing to do.
|
||||||
#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.
|
|
||||||
log "Project reloaded successfully!"
|
log "Project reloaded successfully!"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,9 +38,17 @@ grep_status="$?"
|
|||||||
|
|
||||||
log "Pull status is '$git_status', checking for changes is '$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
|
if [[ $git_status != 0 ]]; then
|
||||||
log "*** ERROR: Git reported a failure! ***"
|
log "*** ERROR: Git reported a failure! ***"
|
||||||
exit 1
|
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
|
elif [[ $git_status == 0 && $grep_status == 0 ]]; then
|
||||||
reload-project
|
reload-project
|
||||||
elif [[ $git_status == 0 && $grep_status != 0 ]]; then
|
elif [[ $git_status == 0 && $grep_status != 0 ]]; then
|
||||||
|
Reference in New Issue
Block a user