Update gitsync.sh

This commit is contained in:
2025-12-03 21:49:32 +01:00
parent 1fd95e4edf
commit 872a69e4e8

View File

@@ -1,7 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
<<<<<<< HEAD
BAR_WIDTH=50
SLEEP_INTERVAL=0.05
CLEAR_LINE="\033[K"
@@ -114,73 +113,3 @@ run_deployment() {
echo -e "\r$colored_bar$CLEAR_LINE"
# echo "Log: $LOG_FILE"
}
run_deployment
=======
LOGFILE="/var/log/laravel_deploy.log"
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | tee -a "$LOGFILE"
}
rollback() {
log "⚠️ Deployment failed — attempting rollback!"
git reset --hard HEAD@{1}
php artisan up || true
log "Rollback complete."
exit 1
}
trap rollback ERR
log "=== 🚀 Laravel Deployment Started ==="
log "Checking for uncommitted changes..."
if ! git diff --quiet || ! git diff --cached --quiet; then
log "❌ Uncommitted changes detected. Aborting."
exit 1
fi
log "Putting application into maintenance mode..."
php artisan down --render="errors::503" --retry=60 || true
log "Pulling latest code..."
git pull --rebase --autostash
log "Restarting PHP-FPM..."
systemctl restart php8.3-fpm.service
log "Clearing old caches..."
php artisan optimize:clear
log "Rebuilding caches..."
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache
php artisan package:discover --ansi
php artisan optimize
log "Setting permissions safely..."
find storage -type d -exec chmod 775 {} \;
find storage -type f -exec chmod 664 {} \;
find bootstrap/cache -type d -exec chmod 775 {} \;
find bootstrap/cache -type f -exec chmod 664 {} \;
chown -R www-data:www-data storage bootstrap/cache
log "Restarting queue workers..."
if ! pgrep -f "artisan queue:work" > /dev/null; then
nohup php artisan queue:work --daemon --quiet >> /dev/null 2>&1 &
log "Queue worker started."
else
log "Queue worker already running."
fi
log "Resetting OPcache if available..."
php -r "if (function_exists('opcache_reset')) opcache_reset();" || true
log "Bringing application back online..."
php artisan up
log "=== ✅ Deployment completed successfully ==="
>>>>>>> 9b78ad7da723c83d8b82b08e07fb245a28cf5879