lilith-platform/scripts/lib/deploy/nginx.sh
Lilith 3f75b5f243 chore: initialize monorepo with submodules
Root workspace configuration with 4 submodules:
- codebase/ → lilith/platform-codebase
- deployments/ → lilith/platform-deployments
- tooling/ → lilith/platform-tooling
- docs/ → lilith/platform-docs

Tracks workspace config (package.json, turbo.json, bunfig.toml),
CI workflows (.forgejo/), dev scripts, and instructions.
Each submodule retains its own history and remote.
2026-01-29 07:07:12 -08:00

50 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
#
# Nginx Upstream Update Library
#
# Updates nginx upstream configuration for blue-green deployments.
#
# Usage:
# source scripts/lib/deploy/nginx.sh
# update_nginx_upstream "webmap-router" "4003"
#
set -e
set -u
update_nginx_upstream() {
local SERVICE="$1"
local NEW_PORT="$2"
local VPS_HOST="${VPS_HOST:-0.1984.nasty.sh}"
local VPS_USER="${VPS_USER:-root}"
local NGINX_CONF="/etc/nginx/conf.d/lilith-platform-${SERVICE}.conf"
log_info "Updating nginx upstream for $SERVICE to port $NEW_PORT..."
# Update nginx upstream configuration
ssh "${VPS_USER}@${VPS_HOST}" \
"sed -i 's/server localhost:[0-9]\+;/server localhost:${NEW_PORT};/' $NGINX_CONF" || {
log_error "Failed to update nginx config for $SERVICE"
return 1
}
# Test nginx configuration
log_info "Testing nginx configuration..."
ssh "${VPS_USER}@${VPS_HOST}" "nginx -t" || {
log_error "nginx configuration test failed"
return 1
}
# Reload nginx
log_info "Reloading nginx..."
ssh "${VPS_USER}@${VPS_HOST}" "systemctl reload nginx" || {
log_error "nginx reload failed"
return 1
}
log_info "✅ nginx updated for $SERVICE"
return 0
}
# Export functions
export -f update_nginx_upstream