Files
autoreg-skills-max/skills/reseller-api-gateway/references/deployment-commands.md

2.3 KiB

Deployment Commands

Immutable release deployment for [REDACTED-NAME] API gateway on VPS ([REDACTED-IP]).

Release ID convention

RELEASE_ID=$(date +%Y%m%d_%H%M%S)
# Example: 20260804_142027

Deploy workflow

set -eu
RELEASE_ID=20260804_142027
SHA=$(sha256sum gateway.py | cut -d' ' -f1)

ssh root@host "mkdir -p /opt/apioid-echo/releases/${RELEASE_ID}"
scp gateway.py root@host:/opt/apioid-echo/releases/${RELEASE_ID}/gateway.py
scp [REDACTED-NAME].nginx.conf root@host:/opt/apioid-echo/releases/${RELEASE_ID}/

ssh root@host "
  R='${RELEASE_ID}'
  # backup
  cp /opt/apioid-echo/releases/current/gateway.py /var/backups/apioid-echo/gateway.before-\${R}.py
  cp /etc/nginx/sites-available/[REDACTED-NAME] /var/backups/apioid-echo/nginx.before-\${R}.conf
  # deploy
  ln -sfn /opt/apioid-echo/releases/\${R} /opt/apioid-echo/releases/current
  chown root:root /opt/apioid-echo/releases/\${R}/*
  chmod 0644 /opt/apioid-echo/releases/\${R}/gateway.py
  cp /opt/apioid-echo/releases/\${R}/[REDACTED-NAME].nginx.conf /etc/nginx/sites-available/[REDACTED-NAME]
  nginx -t && systemctl reload nginx
  systemctl restart apioid-echo-gateway.service
  sleep 1.5
  systemctl is-active apioid-echo-gateway.service
  systemctl show -p NRestarts apioid-echo-gateway.service
"

Live smoke

ssh root@host "
  KEY='rfb_KEY_HERE'
  # health
  curl -sk --noproxy '*' --resolve api.[REDACTED-NAME].loc.cc:443:127.0.0.1 https://api.[REDACTED-NAME].loc.cc/health
  # HTTP/2 + chat
  curl -skI --resolve api.[REDACTED-NAME].loc.cc:443:127.0.0.1 https://api.[REDACTED-NAME].loc.cc/health 2>&1 | head -1
  time curl -sk -H \"Authorization: Bearer \${KEY}\" \
    -H 'Content-Type: application/json' \
    -d '{\"model\":\"rb-902d95ce37cee7204c89\",\"messages\":[{\"role\":\"user\",\"content\":\"hi\"}],\"max_tokens\":3}' \
    https://api.[REDACTED-NAME].loc.cc/v1/chat/completions
"

VPS paths

Path Purpose
/opt/apioid-echo/releases/current/ Active release (symlink)
/opt/apioid-echo/releases/<TS>/ Immutable release directory
/etc/apioid-echo/gateway.env Env (keys, MODEL_ALIAS_SECRET), chmod 600
/etc/nginx/sites-available/[REDACTED-NAME] Nginx config
/var/backups/apioid-echo/ Pre-deploy backups
/etc/systemd/system/apioid-echo-gateway.service systemd unit