Initial commit
This commit is contained in:
35
llamaCpp.Wrapper.app/run.py
Normal file
35
llamaCpp.Wrapper.app/run.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from app.config import load_config
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cfg = load_config()
|
||||
python = sys.executable
|
||||
|
||||
api_cmd = [python, "-m", "uvicorn", "app.api_app:create_api_app", "--factory", "--host", "0.0.0.0", "--port", str(cfg.api_port)]
|
||||
ui_cmd = [python, "-m", "uvicorn", "app.ui_app:create_ui_app", "--factory", "--host", "0.0.0.0", "--port", str(cfg.ui_port)]
|
||||
|
||||
procs = [subprocess.Popen(api_cmd)]
|
||||
if cfg.ui_port != cfg.api_port:
|
||||
procs.append(subprocess.Popen(ui_cmd))
|
||||
|
||||
def shutdown(_sig, _frame):
|
||||
for proc in procs:
|
||||
proc.terminate()
|
||||
for proc in procs:
|
||||
proc.wait(timeout=10)
|
||||
sys.exit(0)
|
||||
|
||||
signal.signal(signal.SIGTERM, shutdown)
|
||||
signal.signal(signal.SIGINT, shutdown)
|
||||
|
||||
for proc in procs:
|
||||
proc.wait()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user