Spaces:
Sleeping

File size: 2,346 Bytes
07ba06f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
72
73
74
75
76
77
78
79
#!/usr/bin/env python3
"""
AirCompute Full Autonomous Production Swarm Launcher
Spins up Genesis Bootstrap UI Node and Auto-Negotiating Miner Nodes seamlessly.
"""
import asyncio
import subprocess
import sys
import os
import time
import httpx

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

def main():
    print("=" * 70)
    print("🚀 AIRCOMPUTE FULL AUTONOMOUS DECENTRALIZED PRODUCT LAUNCHER")
    print("=" * 70)
    
    env = os.environ.copy()
    env["PYTHONUNBUFFERED"] = "1"
    env["PYTHONPATH"] = "."

    # 1. Start Genesis Node & Client UI
    print("1️⃣  Starting Genesis Bootstrap Node & Client UI on http://0.0.0.0:8000 ...")
    ui_proc = subprocess.Popen(
        [sys.executable, "scripts/run_client_ui.py"],
        env=env
    )
    
    # Wait for Client UI & DHT Genesis to initialize
    time.sleep(4)
    
    # 2. Start Auto-Miner 1 (Laptop / High Capacity)
    print("2️⃣  Starting Auto-Miner 1 (Auto-Negotiates Layers based on RAM/FLOPS)...")
    miner1_proc = subprocess.Popen(
        [
            sys.executable, "scripts/run_miner.py",
            "--miner-id", "production_miner_01",
            "--port", "8001",
            "--dht-port", "8470",
            "--bootstrap-ip", "127.0.0.1",
            "--bootstrap-port", "8468"
        ],
        env=env
    )
    
    time.sleep(3)

    # 3. Start Auto-Miner 2 (Secondary Worker / Auto-Negotiates remaining layers)
    print("3️⃣  Starting Auto-Miner 2 (Auto-Negotiates remaining layers)...")
    miner2_proc = subprocess.Popen(
        [
            sys.executable, "scripts/run_miner.py",
            "--miner-id", "production_miner_02",
            "--port", "8002",
            "--dht-port", "8471",
            "--bootstrap-ip", "127.0.0.1",
            "--bootstrap-port", "8468"
        ],
        env=env
    )

    print("\n✅ Full Decentralized Swarm Mesh is running!")
    print("🌐 Open http://localhost:8000 in your browser to access the Chat UI and Swarm Inspector.")
    print("Press Ctrl+C to stop all nodes.\n")

    try:
        ui_proc.wait()
    except KeyboardInterrupt:
        print("\n🛑 Shutting down Swarm Mesh nodes...")
        ui_proc.terminate()
        miner1_proc.terminate()
        miner2_proc.terminate()
        print("Done.")

if __name__ == "__main__":
    main()