Refactor how the project is run, using nginx instead of hugo server, a cron job to pull git changes, and a start script to ensure the correct services are started each run and are monitored to stay up.

This commit is contained in:
2025-08-15 11:45:23 -07:00
parent dfb9a306c5
commit d035f9d8e7
6 changed files with 112 additions and 17 deletions

View File

@@ -0,0 +1,58 @@
#!/usr/bin/env bash
REPO="$1"
echo "REPO=$REPO"
PROD="$2"
typeset -u PROD
echo "PROD=$PROD"
DEV="$3"
typeset -u DEV
echo "DEV=$DEV"
echo "*** Creating Git Repo ***"
sudo -u hugo git clone --recurse-submodules $REPO /var/www/hugo/site
echo "*** Copying Static Files to NGINX ***"
sudo -u hugo /var/www/hugo/cronjob.sh
echo "*** Starting Cron ***"
service cron start
if [[ "$PROD" == "Y"* || "$PROD" == "T"* ]]; then
echo "*** Starting Production Server Loop ***"
while true; do
curl -sS http://localhost:80 > /dev/null || {
echo "* Prod server not detected, starting..."
service nginx start
}
sleep 30
done &
cd /var/log/nginx
tail -f access.log error.log &
fi
if [[ "$DEV" == "Y"* || "$DEV" == "T"* ]]; then
echo "*** Starting Development Server Loop ***"
while true; do
curl -sS http://localhost:1380 > /dev/null || {
echo "* Dev server not detected, starting..."
cd /var/www/hugo/site
killall hugo 2>/dev/null
sudo -u hugo hugo server -D --noBuildLock --bind 0.0.0.0 -p 1380 &
}
sleep 10
done &
fi
cd
echo "*** Finished $0 ***"
wait -n
exit $?