Print default values

This commit is contained in:
Andras Schmelczer 2022-07-03 13:54:29 +02:00
parent 1f4bfd2a24
commit d9a18ac982
2 changed files with 15 additions and 11 deletions

View file

@ -43,9 +43,9 @@ def main() -> None:
args = parse_arguments() args = parse_arguments()
should_auto_reload = not _is_in_production_mode(logger=None) should_auto_reload = not _is_in_production_mode(logger=None)
if args.workers > 1 and should_auto_reload: if args.worker_count > 1 and should_auto_reload:
raise ArgumentValidationError( raise ArgumentValidationError(
"Cannot use auto-reload with multiple workers: set the `--workers=1` CLI argument," "Cannot use auto-reload with multiple worker_count: set the `--worker_count=1` CLI argument,"
+ "or set the ENVIRONMENT environment variable to `production`." + "or set the ENVIRONMENT environment variable to `production`."
) )
@ -53,7 +53,7 @@ def main() -> None:
host=args.host, host=args.host,
port=args.port, port=args.port,
timeout_keep_alive=args.timeout_keep_alive, timeout_keep_alive=args.timeout_keep_alive,
workers=args.workers, workers=args.worker_count,
server_header=False, server_header=False,
reload=False, reload=False,
log_config=GREAT_AI_LOGGING_CONFIG, log_config=GREAT_AI_LOGGING_CONFIG,

View file

@ -12,35 +12,39 @@ def parse_arguments() -> Namespace:
help="the name of the file containing your to-be-served function such as `main.py`\n", help="the name of the file containing your to-be-served function such as `main.py`\n",
) )
default_host = "0.0.0.0"
parser.add_argument( parser.add_argument(
"--host", "--host",
type=str, type=str,
help="it is passed to uvicorn which starts a server listening on this address", help=f"it is passed to uvicorn which starts a server listening on this address (default: {default_host})",
default="0.0.0.0", default=default_host,
required=False, required=False,
) )
default_port = 6060
parser.add_argument( parser.add_argument(
"--port", "--port",
type=int, type=int,
help="it is passed to uvicorn which starts a server listening on this port", help=f"it is passed to uvicorn which starts a server listening on this port (default: {default_port})",
default=6060, default=default_port,
required=False, required=False,
) )
default_timeout_keep_alive = 600
parser.add_argument( parser.add_argument(
"--timeout_keep_alive", "--timeout_keep_alive",
type=int, type=int,
help="it is passed to uvicorn which uses it for timing out requests taking longer than this many seconds", help=f"it is passed to uvicorn which uses it for timing out requests taking longer than this many seconds (default: {default_timeout_keep_alive})",
default=600, default=600,
required=False, required=False,
) )
default_worker_count = 1
parser.add_argument( parser.add_argument(
"--workers", "--worker_count",
type=int, type=int,
help="it is passed to uvicorn which starts this many server processes", help=f"it is passed to uvicorn which starts this many server processes (default: {default_worker_count})",
default=1, default=default_worker_count,
required=False, required=False,
) )