fix(deploy): auto-create static symlinks in sync script
Previously git reset removed symlinks (css, js, images, uploads) which caused Nginx to return 404 for static assets. Now deploy() recreates them after git sync. Refs: production server, admin panel 404 fix
This commit is contained in:
@@ -66,27 +66,23 @@ deploy() {
|
||||
"${BUN}" install --production
|
||||
|
||||
# Fix permissions
|
||||
echo "Fixing permissions..."
|
||||
chown -R nero:nero "$PROJECT_DIR"
|
||||
chmod 600 "$PROJECT_DIR/.env"
|
||||
find "$PROJECT_DIR" -type f -not -path '*/node_modules/*' -exec chmod 644 {} \;
|
||||
find "$PROJECT_DIR" -type d -exec chmod 755 {} \;
|
||||
chmod 644 "$PROJECT_DIR/data/tenerifeprop.db" 2>/dev/null || true
|
||||
|
||||
# Restart
|
||||
echo "=== Restarting $SERVICE ==="
|
||||
systemctl restart "$SERVICE"
|
||||
|
||||
# Healthcheck
|
||||
sleep 2
|
||||
HTTP_CODE=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:3003/api/settings)
|
||||
if [ "$HTTP_CODE" = "200" ]; then
|
||||
echo "✅ Deploy successful. Healthcheck: HTTP 200"
|
||||
# Tag the deploy
|
||||
git tag "deploy-$(date +%Y%m%d-%H%M%S)" || true
|
||||
else
|
||||
echo "❌ Deploy failed. Healthcheck: HTTP $HTTP_CODE"
|
||||
echo "Check logs: journalctl -u $SERVICE --no-pager -n 50"
|
||||
exit 1
|
||||
|
||||
# Create static symlinks (Nginx expects /css, /js, /images at root)
|
||||
echo "Creating static symlinks..."
|
||||
cd "$PROJECT_DIR"
|
||||
ln -sf public/css css 2>/dev/null || true
|
||||
ln -sf public/js js 2>/dev/null || true
|
||||
ln -sf public/images images 2>/dev/null || true
|
||||
ln -sf public/uploads uploads 2>/dev/null || true
|
||||
chown -h nero:nero css js images uploads 2>/dev/null || true
|
||||
|
||||
if [ -f "$PROJECT_DIR/data/tenerifeprop.db" ]; then
|
||||
chmod 644 "$PROJECT_DIR/data/tenerifeprop.db"
|
||||
fi
|
||||
|
||||
echo "=== Deploy completed at $(date) ==="
|
||||
|
||||
Reference in New Issue
Block a user