mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
Merge branch 'almet/fix-serverstart' into 'main'
Call uvicorn via python rather than subprocess See merge request framasoft/framaspace/argos!8
This commit is contained in:
commit
b21399792e
1 changed files with 6 additions and 9 deletions
|
@ -1,7 +1,8 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import subprocess
|
import os
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
import uvicorn
|
||||||
|
|
||||||
from argos import logging
|
from argos import logging
|
||||||
from argos.agent import ArgosAgent
|
from argos.agent import ArgosAgent
|
||||||
|
@ -51,16 +52,12 @@ def agent(server, auth, max_tasks, wait_time, log_level):
|
||||||
@server.command()
|
@server.command()
|
||||||
@click.option("--host", default="127.0.0.1", help="Host to bind")
|
@click.option("--host", default="127.0.0.1", help="Host to bind")
|
||||||
@click.option("--port", default=8000, type=int, help="Port to bind")
|
@click.option("--port", default=8000, type=int, help="Port to bind")
|
||||||
|
@click.option("--config", default="config.yaml", help="Path the the configuration file")
|
||||||
@click.option("--reload", is_flag=True, help="Enable hot reloading")
|
@click.option("--reload", is_flag=True, help="Enable hot reloading")
|
||||||
@click.option("--log-config", help="Path to the logging configuration file")
|
def start(host, port, config, reload):
|
||||||
def start(host, port, reload, log_config):
|
|
||||||
"""Starts the server."""
|
"""Starts the server."""
|
||||||
command = ["uvicorn", "argos.server:app", "--host", host, "--port", str(port)]
|
os.environ["ARGOS_YAML_FILE"] = config
|
||||||
if reload:
|
uvicorn.run("argos.server:app", host=host, port=port, reload=reload)
|
||||||
command.append("--reload")
|
|
||||||
if log_config:
|
|
||||||
command.extend(["--log-config", log_config])
|
|
||||||
subprocess.run(command)
|
|
||||||
|
|
||||||
|
|
||||||
@server.command()
|
@server.command()
|
||||||
|
|
Loading…
Reference in a new issue