Move 想见的人 to 一起做事/找搭子, rename gigs to 招聘, hide skill swap and the motion toggle, keep coffeechat online-backed, and add a non-dismissive feedback orb. Co-authored-by: Cursor <cursoragent@cursor.com>
71 lines
2.2 KiB
Python
71 lines
2.2 KiB
Python
"""One-shot: ensure coffee demo hosts exist on US .com PocketBase. Backend-only."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
US = ("108.174.50.68", "root", "Xiao4669805")
|
|
|
|
REMOTE = r"""
|
|
set -eu
|
|
cd /var/www/nomadro.cn/apps/api
|
|
.venv-social/bin/python - <<'PY'
|
|
import json, os, sys
|
|
from pathlib import Path
|
|
root = Path("/var/www/nomadro.cn/apps/api")
|
|
sys.path.insert(0, str(root))
|
|
sys.path.insert(0, str(root / "services"))
|
|
for line in Path("/etc/nomadro/uiux-services.env").read_text().splitlines():
|
|
if not line.strip() or "=" not in line:
|
|
continue
|
|
k, v = line.split("=", 1)
|
|
try:
|
|
v = json.loads(v)
|
|
except Exception:
|
|
pass
|
|
os.environ[k] = str(v)
|
|
os.environ["COFFEE_SEED_DEMO"] = "1"
|
|
from coffee_svc.pb_store import init_db, list_hosts, get_host
|
|
init_db()
|
|
hosts = list_hosts()
|
|
print("HOST_COUNT", len(hosts))
|
|
print("USERNAMES", ",".join(h.get("username", "") for h in hosts))
|
|
alice = get_host("alice")
|
|
print("ALICE", "ok" if alice else "missing", "events", len((alice or {}).get("event_types") or []))
|
|
PY
|
|
|
|
unit=/etc/systemd/system/nomadro-coffee.service
|
|
if grep -q 'Environment=COFFEE_SEED_DEMO=0' "$unit"; then
|
|
sed -i 's/Environment=COFFEE_SEED_DEMO=0/Environment=COFFEE_SEED_DEMO=1/' "$unit"
|
|
systemctl daemon-reload
|
|
systemctl restart nomadro-coffee
|
|
for i in $(seq 1 20); do
|
|
if curl -fsS --max-time 2 http://127.0.0.1:8024/api/coffee/v1/health >/dev/null; then break; fi
|
|
sleep 1
|
|
done
|
|
fi
|
|
curl -fsS --max-time 8 http://127.0.0.1:8024/api/coffee/v1/hosts/alice | head -c 240; echo
|
|
systemctl is-active nomadro-coffee
|
|
"""
|
|
|
|
|
|
def main() -> int:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(US[0], username=US[1], password=US[2], timeout=30)
|
|
try:
|
|
assert c.get_transport().getpeername()[0] == "108.174.50.68"
|
|
_, out, err = c.exec_command(REMOTE, timeout=180)
|
|
sys.stdout.write(out.read().decode("utf-8", "replace"))
|
|
e = err.read().decode("utf-8", "replace")
|
|
if e.strip():
|
|
sys.stderr.write(e)
|
|
return out.channel.recv_exit_status()
|
|
finally:
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|