mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-08 05:39:13 +00:00
Allow configuring host, port or unix socket of server via CLI
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
# Standard Packages
|
# Standard Packages
|
||||||
import sys
|
import sys
|
||||||
import pathlib
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
# External Packages
|
# External Packages
|
||||||
@@ -121,4 +120,7 @@ if __name__ == '__main__':
|
|||||||
model, search_config = initialize_search(args.config, args.regenerate, args.verbose)
|
model, search_config = initialize_search(args.config, args.regenerate, args.verbose)
|
||||||
|
|
||||||
# Start Application Server
|
# 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)
|
||||||
|
|||||||
@@ -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('--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('--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('--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)
|
args = parser.parse_args(args)
|
||||||
|
|
||||||
if not (args.config_file or args.org_files):
|
if not (args.config_file or args.org_files):
|
||||||
|
|||||||
Reference in New Issue
Block a user