first commit

This commit is contained in:
2026-10-21 15:52:23 +08:00
commit f37510c88f
18 changed files with 5315 additions and 0 deletions

20
examples/launch.py Normal file
View File

@@ -0,0 +1,20 @@
import os,sys,json,resource,subprocess,signal,time
from pathlib import Path
base=Path(__file__).parent
resource.setrlimit(resource.RLIMIT_MEMLOCK,(resource.RLIM_INFINITY,resource.RLIM_INFINITY))
cfg=json.loads((base/"command-serial.json").read_text())
env=os.environ.copy();env.update(cfg["env"])
log=base/(sys.argv[1] if len(sys.argv)>1 else "serve-fixed.log")
with log.open("w") as f:
p=subprocess.Popen(cfg["args"],env=env,stdout=f,stderr=subprocess.STDOUT,start_new_session=True,cwd="/workspace/pytorch")
(base/"serve.pid").write_text(str(p.pid))
print("SERVER_PID",p.pid,"LOG",log,flush=True)
rc=p.wait()
print("SERVER_EXIT",rc,flush=True)
if rc:
try: os.killpg(p.pid,signal.SIGTERM)
except ProcessLookupError: pass
time.sleep(3)
try: os.killpg(p.pid,signal.SIGKILL)
except ProcessLookupError: pass
sys.exit(rc)