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>
60 lines
1.9 KiB
Python
60 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
import sys
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
REMOTE = r"""
|
|
echo "=== nginx location block ==="
|
|
sed -n '/douyin-covers/,/}/p' /etc/nginx/conf.d/dy-nomadro-live.conf
|
|
|
|
echo "=== s3 list covers (auth) ==="
|
|
cd /opt/douyinWEB/backend
|
|
.venv/bin/python - <<'PY'
|
|
import os
|
|
os.environ.setdefault('DY_S3_ENABLED', 'true')
|
|
os.environ.setdefault('DY_S3_ENDPOINT', 'http://127.0.0.1:8333')
|
|
os.environ.setdefault('DY_S3_BUCKET', 'douyin-covers')
|
|
from app import s3_storage, config
|
|
from app.config import settings
|
|
print('enabled', s3_storage.s3_enabled())
|
|
print('bucket', settings.s3_bucket)
|
|
client = s3_storage._client()
|
|
resp = client.list_objects_v2(Bucket=settings.s3_bucket, Prefix='covers/', MaxKeys=8)
|
|
items = resp.get('Contents') or []
|
|
print('objects', len(items))
|
|
for it in items[:5]:
|
|
key = it['Key']
|
|
print(' ', key, 'size', it.get('Size'))
|
|
try:
|
|
url = s3_storage.public_url_for_key(key)
|
|
print(' url', url)
|
|
except Exception as e:
|
|
print(' url err', e)
|
|
|
|
# test one active session cover
|
|
from app import db
|
|
for s in db.list_active_sessions():
|
|
cp = str(s.get('cover_path') or '')
|
|
if 'covers/' in cp:
|
|
key = cp.split('/douyin-covers/', 1)[-1]
|
|
print('session key', key)
|
|
try:
|
|
head = client.head_object(Bucket=settings.s3_bucket, Key=key)
|
|
print(' head ok size', head.get('ContentLength'))
|
|
except Exception as e:
|
|
print(' head FAIL', e)
|
|
break
|
|
PY
|
|
"""
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False)
|
|
_i, o, e = c.exec_command(REMOTE, timeout=120)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
err = e.read().decode("utf-8", "replace").strip()
|
|
if err:
|
|
print("ERR", err[:2000])
|
|
c.close()
|