34
34
def parse_cli_args ():
35
35
"""Parse the command line arguments."""
36
36
parser = argparse .ArgumentParser ()
37
- parser .add_argument ("--host" , type = str , required = False , help = "The host to run the service on. By default 0.0.0.0" )
38
- parser .add_argument ("--port" , type = int , required = False , help = "The port to run the service on. By default 50052" )
39
- parser .add_argument ("--workers" , type = int , required = False , help = "The number of workers to use. By default 4" )
40
- parser .add_argument ("--use-ssl" , required = False , help = "Enable SSL for the service. By default False" )
37
+ parser .add_argument (
38
+ "--host" , type = str , required = False , default = "0.0.0.0" , help = "The host to run the service on. By default 0.0.0.0"
39
+ )
40
+ parser .add_argument (
41
+ "--port" , type = int , required = False , default = "50052" , help = "The port to run the service on. By default 50052"
42
+ )
43
+ parser .add_argument (
44
+ "--workers" , type = int , required = False , default = "4" , help = "The number of workers to use. By default 4"
45
+ )
46
+ parser .add_argument ("--use-ssl" , required = False , default = False , help = "Enable SSL for the service. By default False" )
41
47
parser .add_argument ("--ssl-keyfile" , type = str , required = False , help = "The SSL key file path" )
42
48
parser .add_argument ("--ssl-certfile" , type = str , required = False , help = "The SSL certificate file path" )
43
49
args , _ = parser .parse_known_args ()
@@ -46,9 +52,9 @@ def parse_cli_args():
46
52
47
53
def handle_legacy_port_config ():
48
54
"""Handle legacy port configuration."""
49
- if CONFIG .flowkit_python_address != "" :
55
+ if CONFIG .flowkit_python_address != "" or CONFIG . flowkit_python_address :
50
56
return CONFIG .flowkit_python_address
51
- if CONFIG .flowkit_python_endpoint != "" :
57
+ if CONFIG .flowkit_python_endpoint != "" or CONFIG . flowkit_python_endpoint :
52
58
return CONFIG .flowkit_python_endpoint
53
59
54
60
@@ -58,7 +64,7 @@ def substitute_empty_values(args):
58
64
f"{ args .host } :{ args .port } " if args .host is not None and args .port is not None else CONFIG .flowkit_python_address
59
65
)
60
66
CONFIG .flowkit_python_workers = args .workers or CONFIG .flowkit_python_workers
61
- CONFIG .use_ssl = ( args .use_ssl . lower () == "true" ) if args . use_ssl is not None else CONFIG .use_ssl
67
+ CONFIG .use_ssl = args .use_ssl or CONFIG .use_ssl
62
68
CONFIG .ssl_cert_private_key_file = args .ssl_keyfile or CONFIG .ssl_cert_private_key_file
63
69
CONFIG .ssl_cert_public_key_file = args .ssl_certfile or CONFIG .ssl_cert_public_key_file
64
70
return
@@ -74,11 +80,11 @@ def main():
74
80
substitute_empty_values (args )
75
81
76
82
address = handle_legacy_port_config ()
77
- # Add scheme if missing
83
+ # # Add scheme if missing
78
84
if not address .startswith (("http://" , "https://" )):
79
85
address = "http://" + address
80
- host = urlparse (address ).hostname
81
- port = urlparse (address ).port
86
+ host = urlparse (address ).hostname or args . host
87
+ port = urlparse (address ).port or args . port
82
88
83
89
# Run the service
84
90
uvicorn .run (
0 commit comments