hi
This commit is contained in:
commit
2bbacd2c7d
8 files changed
+582
No files matched your search
@@ -0,0 +1,37 @@
|
||||
"""Start both local projects. Ctrl+C stops both services."""
|
||||
import argparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
ROOT=Path(__file__).resolve().parent
|
||||
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser()
|
||||
parser.add_argument("--port",type=int,default=5173)
|
||||
parser.add_argument("--api-port",type=int,default=8787)
|
||||
parser.add_argument("--data-dir",type=Path,default=ROOT.parent/"licensing"/"data")
|
||||
args=parser.parse_args()
|
||||
environment=os.environ.copy()
|
||||
environment["AMNESIA_ORIGIN"]=f"http://127.0.0.1:{args.port}"
|
||||
environment["AMNESIA_DATA"]=str(args.data_dir.resolve())
|
||||
processes=[]
|
||||
try:
|
||||
processes.append(subprocess.Popen([sys.executable,"-u",str(ROOT.parent/"licensing"/"run.py"),"--dev","--port",str(args.api_port)],env=environment))
|
||||
processes.append(subprocess.Popen([sys.executable,"-u",str(ROOT/"serve.py"),"--port",str(args.port),"--api-port",str(args.api_port)],env=environment))
|
||||
print(f"Open http://127.0.0.1:{args.port} — press Ctrl+C to stop both projects.",flush=True)
|
||||
while all(process.poll() is None for process in processes):time.sleep(.25)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
finally:
|
||||
for process in processes:
|
||||
if process.poll() is None:process.terminate()
|
||||
for process in processes:
|
||||
try:process.wait(timeout=5)
|
||||
except subprocess.TimeoutExpired:process.kill();process.wait()
|
||||
|
||||
|
||||
if __name__=="__main__":main()
|
||||
Reference in new issue
Block a user