Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
85 lines
3.1 KiB
Python
85 lines
3.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Retry Seaweed bucket on PVE guest only. Verify empty rooms + live sites."""
|
|
import sys
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
v = paramiko.SSHClient()
|
|
v.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
v.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=25, allow_agent=False, look_for_keys=False)
|
|
|
|
p = paramiko.SSHClient()
|
|
p.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
p.connect("107.173.30.245", 4014, "eric", "4669805", timeout=25, allow_agent=False, look_for_keys=False)
|
|
|
|
|
|
def run(c, cmd, timeout=60):
|
|
_, o, e = c.exec_command(cmd, timeout=timeout)
|
|
return (o.read() + e.read()).decode("utf-8", "replace")
|
|
|
|
|
|
print("=== PVE seaweed/s3 ===")
|
|
print(run(p, "echo '4669805' | sudo -S -p '' systemctl is-active douyinweb-s3 douyinweb-sw-filer douyinweb-sw-volume douyinweb-sw-master; ss -lntp | grep -E ':(8333|8014|4015|8092)\\b'"))
|
|
print(run(
|
|
p,
|
|
r"""echo '4669805' | sudo -S -p '' bash -c '
|
|
set -a; source /etc/douyinweb.env; set +a
|
|
cd /opt/douyinWEB/backend
|
|
.venv/bin/python - <<PY
|
|
import os, boto3
|
|
from botocore.client import Config
|
|
c=boto3.client("s3", endpoint_url=f"http://127.0.0.1:{os.environ["S3_PORT"]}",
|
|
aws_access_key_id=os.environ["S3_ACCESS"], aws_secret_access_key=os.environ["S3_SECRET"],
|
|
region_name="us-east-1", config=Config(signature_version="s3v4", s3={"addressing_style":"path"}))
|
|
try:
|
|
c.create_bucket(Bucket=os.environ["S3_BUCKET"])
|
|
print("bucket created")
|
|
except Exception as e:
|
|
print("bucket", e)
|
|
print(c.list_buckets())
|
|
PY
|
|
'""",
|
|
40,
|
|
))
|
|
print("=== rooms (must be empty) ===")
|
|
print(run(
|
|
p,
|
|
r"""echo '4669805' | sudo -S -p '' bash -c 'ls -l /opt/douyinWEB/backend/data/; sqlite3 /opt/douyinWEB/backend/data/monitor.db "select count(*) from rooms;" 2>/dev/null || python3 - <<"PY"
|
|
import sqlite3
|
|
p="/opt/douyinWEB/backend/data/monitor.db"
|
|
c=sqlite3.connect(p)
|
|
print("tables", [r[0] for r in c.execute("select name from sqlite_master where type=\\047table\\047")])
|
|
try:
|
|
print("rooms", c.execute("select count(*) from rooms").fetchone()[0])
|
|
except Exception as e:
|
|
print("rooms_err", e)
|
|
PY
|
|
'""",
|
|
20,
|
|
))
|
|
|
|
print("=== public checks ===")
|
|
print(run(
|
|
v,
|
|
"curl -sS -m 12 -o /dev/null -w 'dylive_api:%{http_code} dylive_login:%{http_code}\\n' "
|
|
"https://dylive.nomadro.com/api/health https://dylive.nomadro.com/login; "
|
|
"curl -sS -m 15 -o /dev/null -w 'dy_api:%{http_code} dy_login:%{http_code}\\n' "
|
|
"https://dy.nomadro.com/api/health https://dy.nomadro.com/login; "
|
|
"systemctl is-active caddy sing-box; "
|
|
"docker ps --format '{{.Names}} {{.Status}}' | grep -v wg-easy",
|
|
40,
|
|
))
|
|
# the dual url curl -w trick is wrong; do separately
|
|
print(run(
|
|
v,
|
|
"curl -sS -m 10 -o /dev/null -w 'dylive_api:%{http_code}\\n' https://dylive.nomadro.com/api/health; "
|
|
"curl -sS -m 10 -o /dev/null -w 'dylive_login:%{http_code}\\n' https://dylive.nomadro.com/login; "
|
|
"curl -sS -m 15 -o /dev/null -w 'dy_api:%{http_code}\\n' https://dy.nomadro.com/api/health; "
|
|
"curl -sS -m 15 -o /dev/null -w 'dy_login:%{http_code}\\n' https://dy.nomadro.com/login",
|
|
40,
|
|
))
|
|
|
|
v.close()
|
|
p.close()
|