SPB Git
6.8 KB · 123 lines python
1"""maclustr-dispatch — configuration centrale.23Tout tourne SUR la passerelle (M1M32). Python 3.9 (système macOS) : pas de syntaxe > 3.9.4"""5import os67USER = "simon-pierreboucher"8HOME = os.path.expanduser("~")9GATEWAY = "M1M32"10DOMAIN = "maclustr.io"11LAN_PREFIX = "192.168.2."12SSH_KEY = os.path.join(HOME, ".ssh", "id_ed25519")          # clé « maclustr-m1m32 », autorisée sur tous les nœuds13STATE = os.path.join(HOME, "dispatch")                          # état : apps/, stage/, registry.json, lan.json, logs/14APPS_DIR = os.path.join(STATE, "apps")15STAGE_DIR = os.path.join(STATE, "stage")16LOG_DIR = os.path.join(STATE, "logs")17REGISTRY = os.path.join(STATE, "registry.json")18LAN_CACHE = os.path.join(STATE, "lan.json")19SCAN_CACHE = os.path.join(STATE, "scan.json")20NGROK_CFG = os.path.join(HOME, "Library", "Application Support", "ngrok", "ngrok.yml")21RUN_DIR = "~/dispatch-run"                                      # sur les nœuds : ecosystem PM2 générés22SUDO_PW_FILE = os.path.join(STATE, ".sudo")                     # mot de passe sudo des nœuds (0600), pour `prepare`2324# Inventaire statique (alias -> cœurs, RAM Go, modèle). Les IP LAN sont découvertes en live.25NODES = {26    "M3U96a": {"cores": 32, "ram_gb": 96, "model": "Mac Studio"},27    "M3U96b": {"cores": 32, "ram_gb": 96, "model": "Mac Studio"},28    "M2U64":  {"cores": 24, "ram_gb": 64, "model": "Mac Studio"},29    "M4M64a": {"cores": 16, "ram_gb": 64, "model": "Mac Studio"},30    "M4M64b": {"cores": 16, "ram_gb": 64, "model": "Mac Studio"},31    "M4BP48": {"cores": 16, "ram_gb": 48, "model": "MacBook Pro"},32    "M4BP36": {"cores": 14, "ram_gb": 36, "model": "MacBook Pro"},33    "M4M36":  {"cores": 14, "ram_gb": 36, "model": "Mac Studio"},34    "M2M32":  {"cores": 12, "ram_gb": 32, "model": "Mac Studio"},35    "M2M32b": {"cores": 12, "ram_gb": 32, "model": "Mac Studio"},36    "M2M32c": {"cores": 12, "ram_gb": 32, "model": "Mac Studio"},37    "m4mc":   {"cores": 12, "ram_gb": 24, "model": "Mac mini"},38    "M1M32":  {"cores": 10, "ram_gb": 32, "model": "Mac Studio"},39    "m4ma":   {"cores": 10, "ram_gb": 24, "model": "Mac mini"},40    "m4mb":   {"cores": 10, "ram_gb": 16, "model": "Mac mini"},41    "m2m16":  {"cores": 10, "ram_gb": 16, "model": "Mac mini"},42    "M3BA24": {"cores": 8,  "ram_gb": 24, "model": "MacBook Air"},43    "M3BA16": {"cores": 8,  "ram_gb": 16, "model": "MacBook Air"},44    "m2m8a":  {"cores": 8,  "ram_gb": 8,  "model": "Mac mini"},45    "m2m8b":  {"cores": 8,  "ram_gb": 8,  "model": "Mac mini"},46    "m4md":   {"cores": 10, "ram_gb": 16, "model": "Mac mini"},      # ajouté 2026-09-04 (Mac16,10, M4, 100.78.227.79)47    "M1M64":  {"cores": 10, "ram_gb": 64, "model": "Mac Studio"},    # ajouté 2026-09-08 (Mac13,1, M1 Max, loué, hors LAN — voir REMOTE_NODES)48    "m2m16b": {"cores": 10, "ram_gb": 16, "model": "Mac mini"},      # ajouté 2026-09-08 (Mac14,12, M2 Pro, loué, hors LAN — voir REMOTE_NODES)49    "m1m16":  {"cores": 8,  "ram_gb": 16, "model": "Mac mini"},      # ajouté 2026-09-08 (Macmini9,1, M1, loué, hors LAN — voir REMOTE_NODES)50    "m2m16c": {"cores": 8,  "ram_gb": 16, "model": "Mac mini"},      # ajouté 2026-09-08 (Mac14,3, M2, loué, hors LAN — voir REMOTE_NODES)51}5253# Nœuds HORS LAN : IP publique fixe + autre utilisateur + autre mot de passe sudo. Ils ne sont pas trouvés par le54# balayage 192.168.2.x : `discover` s'y connecte directement et vérifie le marqueur ~/.maclustr-node.55REMOTE_NODES = {56    "M1M64": {"host": "45.74.241.221", "user": "simon", "sudo_pw_file": os.path.join(STATE, ".sudo-M1M64")},57    "m2m16b": {"host": "208.52.154.68", "user": "administrator", "sudo_pw_file": os.path.join(STATE, ".sudo-m2m16b")},58    "m1m16":  {"host": "207.254.29.71", "user": "administrator", "sudo_pw_file": os.path.join(STATE, ".sudo-m1m16")},59    "m2m16c": {"host": "207.254.29.128", "user": "administrator", "sudo_pw_file": os.path.join(STATE, ".sudo-m2m16c")},60}616263def _remote(key):64    for alias, r in REMOTE_NODES.items():65        if key in (alias, r["host"]):66            return r67    return None686970def user_of(key=None):71    """Utilisateur SSH d'un nœud (alias ou IP) — simon-pierreboucher partout sauf REMOTE_NODES."""72    r = _remote(key) if key else None73    return r["user"] if r else USER747576def home_of(key=None):77    return "/Users/%s" % user_of(key)787980def sudo_pw_file(key=None):81    r = _remote(key) if key else None82    return r["sudo_pw_file"] if r else SUDO_PW_FILE838485# Nœuds réservés : inéligibles au placement automatique (sauf app épinglée dessus).86RESERVED = {87    "M3U96b": "réservé à hfmarketdata (lac FirstRate Data) depuis le 2026-09-04",88    "M1M64": "nœud distant hors LAN (loué, user simon) : pas de LAN 192.168.2.x ni de gardiens Ka → placement seulement avec --node",89    "m2m16b": "nœud distant hors LAN (loué, user administrator) : pas de LAN 192.168.2.x ni de gardiens Ka → placement seulement avec --node",90    "m1m16": "nœud distant hors LAN (loué, user administrator) : pas de LAN 192.168.2.x ni de gardiens Ka → placement seulement avec --node",91    "m2m16c": "nœud distant hors LAN (loué, user administrator) : pas de LAN 192.168.2.x ni de gardiens Ka → placement seulement avec --node",92}9394# Rôles : gateway = jamais d'app ; worker = éligible. Un nœud absent du scan est « offline ».95ROLES = {alias: ("gateway" if alias == GATEWAY else "worker") for alias in NODES}9697# Runtimes que `prepare` sait installer via Homebrew, et comment les détecter sur un nœud.98RUNTIME_CHECKS = {99    "node":        "test -x /opt/homebrew/bin/node",100    "pnpm":        "test -x /opt/homebrew/bin/pnpm",101    "pm2":         "test -x /opt/homebrew/bin/pm2",102    "ngrok":       "(test -x /opt/homebrew/bin/ngrok || test -x $HOME/bin/ngrok) && test -f \"$HOME/Library/Application Support/ngrok/ngrok.yml\"",103    "python@3.14": "test -x /opt/homebrew/opt/python@3.14/bin/python3.14",104    "python@3.13": "test -x /opt/homebrew/opt/python@3.13/bin/python3.13",105    "python@3.12": "test -x /opt/homebrew/opt/python@3.12/bin/python3.12",106    "uv":          "test -x /opt/homebrew/bin/uv || test -x $HOME/.local/bin/uv",107    "uv-python@3.12": "ls -d $HOME/.local/share/uv/python/cpython-3.12* >/dev/null 2>&1",108    "redis":       "test -x /opt/homebrew/bin/redis-server && redis-cli ping >/dev/null 2>&1",109    "docker":      "test -x /opt/homebrew/bin/docker",110    "postgresql@17": "test -x /opt/homebrew/opt/postgresql@17/bin/postgres",111    "brew":        "test -x /opt/homebrew/bin/brew",112    "git":         "test -x /opt/homebrew/bin/git || test -x /usr/bin/git",113}114BREW_FORMULAE = {115    "node": "node", "pnpm": "pnpm", "pm2": "pm2", "python@3.14": "python@3.14", "python@3.13": "python@3.13",116    "python@3.12": "python@3.12", "uv": "uv", "redis": "redis", "docker": "docker", "postgresql@17": "postgresql@17", "git": "git",117}118BREW_CASKS = {"ngrok": "ngrok"}119120os.makedirs(APPS_DIR, exist_ok=True)121os.makedirs(STAGE_DIR, exist_ok=True)122os.makedirs(LOG_DIR, exist_ok=True)123
Files · bd5cfbdb1f01a3f2673352ffb71c105498084c12
Menu

Theme