's'
This commit is contained in:
28
scripts/ssh-verify-prod.py
Normal file
28
scripts/ssh-verify-prod.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Quick production health checks after deploy."""
|
||||
from __future__ import annotations
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST = "82.157.112.245"
|
||||
USER = "ubuntu"
|
||||
PASSWORD = "Xiao4669805"
|
||||
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()
|
||||
Reference in New Issue
Block a user