31 lines
1003 B
Python
31 lines
1003 B
Python
#!/usr/bin/env python3
|
|
"""Quick production health checks after deploy."""
|
|
from __future__ import annotations
|
|
|
|
import paramiko
|
|
|
|
from load_dev_env import ssh_config
|
|
|
|
HOST, USER, PASSWORD = ssh_config()
|
|
|
|
|
|
REPO = "/home/ubuntu/gitlab-instance-0a899031_cnomadcna"
|
|
|
|
cmds = [
|
|
"curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8000/docs",
|
|
f"test -f {REPO}/backend/ntfy_push.py && echo ntfy_push:ok",
|
|
"grep -E '^(NTFY_|LISTMONK_)' /home/ubuntu/gitlab-instance-0a899031_cnomadcna/.env.local | sed 's/=.*/=***/'",
|
|
"systemctl is-active cnomadcna-api.service",
|
|
"systemctl is-active cnomadcna.service",
|
|
"systemctl cat cnomadcna.service | head -20",
|
|
]
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, username=USER, password=PASSWORD, timeout=30)
|
|
for cmd in cmds:
|
|
_, o, _ = c.exec_command(f"echo '{PASSWORD}' | sudo -S bash -lc \"{cmd}\"", timeout=60)
|
|
out = o.read().decode().strip()
|
|
print(f"$ {cmd}\n -> {out}\n")
|
|
c.close()
|