Prepare immutable release recovery automation and deployment safeguards

This commit is contained in:
2026-11-26 02:05:13 -05:00
parent 151c59564d
commit 799a377cc0
8 changed files with 773 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -euo pipefail
SSH_KEY="$HOME/.ssh/ssw590_digitalocean"
HOST="root@git.nageshwaran.dev"
ssh -T \
-o BatchMode=yes \
-o StrictHostKeyChecking=yes \
-o ConnectTimeout=10 \
-o ServerAliveInterval=10 \
-o ServerAliveCountMax=3 \
-i "$SSH_KEY" \
"$HOST" \
'bash -c "
set -eu
exec 9>/run/lock/chapter6-production.lock
if ! flock -n 9; then
echo LOCK_BUSY
exit 75
fi
echo PRODUCTION_LOCK_ACQUIRED
date -u
while IFS= read -r command; do
if [ \"\$command\" = RELEASE ]; then
echo PRODUCTION_LOCK_RELEASED
exit 0
fi
done
"'
@@ -0,0 +1,53 @@
import datetime
import json
import time
import urllib.request
import urllib.error
URL = "https://pricing.nageshwaran.dev/health"
print("timestamp_utc,http_status,healthy,version,latency_ms",
flush=True)
try:
while True:
started = time.monotonic()
timestamp = datetime.datetime.now(
datetime.timezone.utc
).isoformat(timespec="milliseconds")
status = 0
healthy = False
version = "unknown"
try:
with urllib.request.urlopen(URL, timeout=3) as response:
status = response.status
data = json.load(response)
healthy = (
status == 200
and data.get("status") == "healthy"
)
version = data.get("version", "not-reported")
except urllib.error.HTTPError as error:
status = error.code
except Exception:
pass
latency = round(
(time.monotonic() - started) * 1000
)
print(
f"{timestamp},{status},{str(healthy).lower()},"
f"{version},{latency}",
flush=True
)
elapsed = time.monotonic() - started
time.sleep(max(0, 1 - elapsed))
except KeyboardInterrupt:
pass
+28
View File
@@ -0,0 +1,28 @@
release: v1
image: git.nageshwaran.dev/ssw590-startup/startup-pricing@sha256:d0d0a2c2052b01a33ce12fd2b278e906552ea9797b5b918f44e5065f444d3027
environment: production
container_name: startup-pricing-production
network: gitea_gitea_internal
host_binding: "127.0.0.1:5061:5000"
application_port: 5000
workers: 2
user: appuser
memory: 64m
memory_swap: 128m
cpus: 0.5
pids_limit: 64
read_only: true
tmpfs: "/tmp:rw,nosuid,nodev,size=16m"
restart_policy: unless-stopped
no_new_privileges: true
cap_drop: ALL
health_url: https://pricing.nageshwaran.dev/health
pricing_url: https://pricing.nageshwaran.dev/pricing
expected_health: healthy
expected_pricing:
Basic: 10
Pro: 25
Enterprise: 50
expected_total: 85
source_commit: unverified
configuration_provenance: reconstructed_recovery_record
+29
View File
@@ -0,0 +1,29 @@
release: v2
image: git.nageshwaran.dev/ssw590-startup/startup-pricing@sha256:14d520f6fbe60c9cc5e661551a03e944de3a2ad777a64c316ec397ee765db22d
environment: production
container_name: startup-pricing-production
network: gitea_gitea_internal
host_binding: "127.0.0.1:5061:5000"
application_port: 5000
workers: 2
user: appuser
memory: 64m
memory_swap: 128m
cpus: 0.5
pids_limit: 64
read_only: true
tmpfs: "/tmp:rw,nosuid,nodev,size=16m"
restart_policy: unless-stopped
no_new_privileges: true
cap_drop: ALL
health_url: https://pricing.nageshwaran.dev/health
pricing_url: https://pricing.nageshwaran.dev/pricing
expected_health: healthy
expected_pricing:
Starter: 5
Basic: 12
Pro: 30
Enterprise: 60
expected_total: 107
source_commit: unverified
configuration_provenance: reconstructed_recovery_record