-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathstart.py
More file actions
71 lines (57 loc) · 1.7 KB
/
start.py
File metadata and controls
71 lines (57 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import argparse
import os
import subprocess
import sys
import signal
import time
processes = []
def cleanup(sig=None, frame=None):
for p in processes:
p.terminate()
for p in processes:
try:
p.wait(timeout=5)
except subprocess.TimeoutExpired:
p.kill()
sys.exit(0)
signal.signal(signal.SIGTERM, cleanup)
signal.signal(signal.SIGINT, cleanup)
def main():
parser = argparse.ArgumentParser(description="Matrix CTF Launcher")
parser.add_argument(
"--openaikey",
required=False,
help="OpenAI API key (e.g. sk-proj-...). Optional — agent uses fallback responses without it.",
)
args = parser.parse_args()
if args.openaikey:
os.environ["OPENAI_API_KEY"] = args.openaikey
# Start the Architect's Vault (port 7001)
vault_proc = subprocess.Popen(
[
sys.executable, "-m", "uvicorn",
"vault.vault:app",
"--host", "0.0.0.0",
"--port", "7001",
"--log-level", "info",
],
env=os.environ.copy(),
)
processes.append(vault_proc)
# Start Agent Smith (port 9999)
smith_proc = subprocess.Popen(
[sys.executable, "agent_smith/__main__.py"],
env=os.environ.copy(),
)
processes.append(smith_proc)
print("[Matrix] Architect's Vault online at port 7001")
print("[Matrix] Agent Smith online at port 9999")
print("[Matrix] The Matrix has you, Neo...")
while True:
for p in processes:
if p.poll() is not None:
print(f"[Matrix] Process {p.pid} exited with code {p.returncode}")
cleanup()
time.sleep(1)
if __name__ == "__main__":
main()