Modify script to remove NGINX default files and check HTTP codes rather than curl response status.

This commit is contained in:
2025-08-17 11:01:10 -07:00
parent 57ade9f67d
commit d6e1186d86

View File

@@ -21,21 +21,27 @@ if [[ $status != 0 || ! -d /var/www/hugo/site/.git ]]; then
echo "Aborting." echo "Aborting."
exit 1 exit 1
fi fi
echo "* Site exists!"
echo "*** Copying Static Files to NGINX ***" echo "*** Copying Static Files to NGINX ***"
rm -rfv /var/www/html/*
sudo -u hugo /var/www/hugo/cronjob.sh sudo -u hugo /var/www/hugo/cronjob.sh
echo "*** Starting Cron ***" echo "*** Starting Cron ***"
service cron start service cron start
service cron status
if [[ "$PROD" == "Y"* || "$PROD" == "T"* ]]; then if [[ "$PROD" == "Y"* || "$PROD" == "T"* ]]; then
echo "*** Starting Production Server Loop ***" echo "*** Starting Production Server Loop ***"
while true; do while true; do
curl -sS http://localhost:80 > /dev/null || { http_code="`curl -sS http://localhost:80 -o /dev/null -w "%{http_code}"`"
if [[ $http_code != 200 ]]; then
echo "* Prod server not detected, starting..." echo "* Prod server not detected, starting..."
service nginx status
service nginx start service nginx start
} service nginx status
fi
sleep 15 sleep 15
done & done &
@@ -47,19 +53,20 @@ if [[ "$DEV" == "Y"* || "$DEV" == "T"* ]]; then
echo "*** Starting Development Server Loop ***" echo "*** Starting Development Server Loop ***"
while true; do while true; do
curl -sS http://localhost:1380 > /dev/null || { http_code="`curl -sS http://localhost:1380 -o /dev/null -w "%{http_code}"`"
if [[ $http_code != 200 ]]; then
echo "* Dev server not detected, starting..." echo "* Dev server not detected, starting..."
cd /var/www/hugo/site cd /var/www/hugo/site
killall hugo 2>/dev/null killall hugo 2>/dev/null
sudo -u hugo hugo server -D --noBuildLock --bind 0.0.0.0 -p 1380 & sudo -u hugo hugo server -D --noBuildLock --bind 0.0.0.0 -p 1380 &
} fi
sleep 30 sleep 30
done & done &
fi fi
cd cd
echo "*** Finished $0 ***" echo "*** Finished $0 @ `date` ***"
wait -n wait -n