Compare commits
2 Commits
2c3b5056ae
...
2a915fec69
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a915fec69 | |||
| fa0e9907ee |
19
cronjob.sh
19
cronjob.sh
@@ -4,26 +4,37 @@
|
|||||||
# project so that docker container can do periodic git pulls rather than having
|
# project so that docker container can do periodic git pulls rather than having
|
||||||
# to reload /rebuild the container each time a release is pushed out.
|
# to reload /rebuild the container each time a release is pushed out.
|
||||||
|
|
||||||
|
## Setup ##
|
||||||
|
|
||||||
DIR="$(dirname -- "${BASH_SOURCE[0]}")"
|
DIR="$(dirname -- "${BASH_SOURCE[0]}")"
|
||||||
PROG="$(basename -- "${BASH_SOURCE[0]}")"
|
PROG="$(basename -- "${BASH_SOURCE[0]}")"
|
||||||
|
cd $DIR
|
||||||
|
DIR="`pwd`"
|
||||||
|
NAME="'$PROG'"
|
||||||
|
|
||||||
|
function log {
|
||||||
|
echo -e "`date` : $NAME - $1"
|
||||||
|
}
|
||||||
|
|
||||||
function reload-project {
|
function reload-project {
|
||||||
## Kill node.js which will complete run.sh and restart any Docker containers.
|
## Kill node.js which will complete run.sh and restart any Docker containers.
|
||||||
#pkill node
|
#pkill node
|
||||||
# Do not kill program, just use the new files and if run.sh or main.js were
|
# 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.
|
# changed then they can get reloaded manually or by the nightly backup.
|
||||||
echo "Project reloaded successfully!"
|
log "Project reloaded successfully!"
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "*** Running '$DIR/$PROG' @ `date` ***"
|
## Main ##
|
||||||
|
|
||||||
|
log "Checking for updates..."
|
||||||
cd $DIR
|
cd $DIR
|
||||||
|
|
||||||
# Pull any updates, and if the project is already up to date, exit successfully.
|
# Pull any updates, and if the project is already up to date, exit successfully.
|
||||||
git pull | grep -v "up to date"
|
git pull | grep -v "up to date"
|
||||||
status="$?"
|
status="$?"
|
||||||
echo "* Pull status is '$status'."
|
log "Pull status is '$status'."
|
||||||
if [[ $status != 0 ]]; then
|
if [[ $status != 0 ]]; then
|
||||||
echo "* Site is already up to date, exiting."
|
log "Site is already up to date, exiting."
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
reload-project
|
reload-project
|
||||||
|
|||||||
14
run.sh
14
run.sh
@@ -6,7 +6,12 @@
|
|||||||
|
|
||||||
DIR="$(dirname -- "${BASH_SOURCE[0]}")"
|
DIR="$(dirname -- "${BASH_SOURCE[0]}")"
|
||||||
PROG="$(basename -- "${BASH_SOURCE[0]}")"
|
PROG="$(basename -- "${BASH_SOURCE[0]}")"
|
||||||
echo "$DIR/$PROG"
|
|
||||||
|
# Ensure we are executing from this file's directory.
|
||||||
|
cd $DIR
|
||||||
|
DIR="`pwd`"
|
||||||
|
NAME="'$DIR/$PROG'"
|
||||||
|
echo $NAME
|
||||||
|
|
||||||
## Functions ##
|
## Functions ##
|
||||||
|
|
||||||
@@ -27,13 +32,15 @@ function log {
|
|||||||
echo -e "`date` - $message"
|
echo -e "`date` - $message"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log "Local process information:"
|
||||||
|
ps $$
|
||||||
function check_main {
|
function check_main {
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
echo "ERROR: Subprocess name was not provided. $1"
|
echo "ERROR: Subprocess name was not provided. $1"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
log "Subprocess '$1' checking if main process is still running..."
|
log "Subprocess '$1' checking if main process is still running..."
|
||||||
ps $$
|
ps $$ >/dev/null
|
||||||
status=$?
|
status=$?
|
||||||
if [[ $status != 0 ]]; then
|
if [[ $status != 0 ]]; then
|
||||||
log "Process '$$' not found, '$1' from '$DIR/$PROG' exiting."
|
log "Process '$$' not found, '$1' from '$DIR/$PROG' exiting."
|
||||||
@@ -62,9 +69,6 @@ fi
|
|||||||
|
|
||||||
## Build Environment ##
|
## Build Environment ##
|
||||||
|
|
||||||
# Ensure we are executing from this file's directory.
|
|
||||||
cd $DIR
|
|
||||||
|
|
||||||
sudo=""
|
sudo=""
|
||||||
if [[ -z $LOGNAME ]]; then
|
if [[ -z $LOGNAME ]]; then
|
||||||
LOGNAME="`whoami`"
|
LOGNAME="`whoami`"
|
||||||
|
|||||||
Reference in New Issue
Block a user