Use a parent process checker for both forked jobs.
This commit is contained in:
18
run.sh
18
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 &
|
||||
|
Reference in New Issue
Block a user