367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
20 lines
1.2 KiB
Python
20 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Start the local relay with private account bindings and a persistent diagnostic log."""
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
front=json.loads((ROOT/'secrets/forever-local/account.json').read_text())
|
|
back_dirs=[p for p in (ROOT/'secrets').iterdir() if p.name.startswith('GW') and (p/'account.json').exists()]
|
|
if len(back_dirs)!=1: raise RuntimeError('Specify a single disposable backend account directory')
|
|
back=back_dirs[0]; account=json.loads((back/'account.json').read_text())
|
|
command=[str(ROOT/'build/gateway-relay'),str(ROOT/'secrets/forever-local/provider.txt'),str(front['account_id']),account['username'],
|
|
str(back/'password.txt'),str(back/'version-hash.bin'),str(back/'addon-tail.bin'),str(front['relay_port'])]
|
|
(ROOT/'runtime').mkdir(exist_ok=True,mode=0o700)
|
|
fd=os.open(ROOT/'runtime/relay.log',os.O_WRONLY|os.O_CREAT|os.O_APPEND,0o600)
|
|
with os.fdopen(fd,'ab') as log:
|
|
p=subprocess.Popen(command,cwd=ROOT,stdout=log,stderr=subprocess.STDOUT,start_new_session=True)
|
|
(ROOT/'runtime/relay.pid').write_text(str(p.pid))
|
|
print('Started local gateway pid',p.pid,'; log runtime/relay.log; account passwords omitted.')
|