Allow configuring host, port or unix socket of server via CLI

This commit is contained in:
Debanjum Singh Solanky 2021-10-02 16:16:33 -07:00
parent 866ccb5cd3
commit c47a8cdf16
2 changed files with 8 additions and 2 deletions

View file

@ -1,6 +1,5 @@
# Standard Packages
import sys
import pathlib
from typing import Optional
# External Packages
@ -121,4 +120,7 @@ if __name__ == '__main__':
model, search_config = initialize_search(args.config, args.regenerate, args.verbose)
# Start Application Server
uvicorn.run(app)
if args.socket:
uvicorn.run(app, proxy_headers=True, uds=args.socket)
else:
uvicorn.run(app, host=args.host, port=args.port)

View file

@ -19,6 +19,10 @@ def cli(args=None):
parser.add_argument('--config-file', '-c', type=pathlib.Path, help="YAML file with user configuration")
parser.add_argument('--regenerate', action='store_true', default=False, help="Regenerate model embeddings from source files. Default: false")
parser.add_argument('--verbose', '-v', action='count', default=0, help="Show verbose conversion logs. Default: 0")
parser.add_argument('--host', type=str, default='127.0.0.1', help="Host address of the server. Default: 127.0.0.1")
parser.add_argument('--port', '-p', type=int, default=8000, help="Port of the server. Default: 8000")
parser.add_argument('--socket', type=pathlib.Path, help="Path to UNIX socket for server. Use to run server behind reverse proxy. Default: /tmp/uvicorn.sock")
args = parser.parse_args(args)
if not (args.config_file or args.org_files):