Skip to content

Commit

Permalink
Add Optional SSL Support to controller.py (#2448)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonbiggs authored Sep 19, 2023
1 parent e4758da commit 68f1fac
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion fastchat/serve/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from enum import Enum, auto
import json
import logging
import os
import time
from typing import List, Union
import threading
Expand Down Expand Up @@ -318,6 +319,13 @@ def create_controller():
choices=["lottery", "shortest_queue"],
default="shortest_queue",
)
parser.add_argument(
"--ssl",
action="store_true",
required=False,
default=False,
help="Enable SSL. Requires OS Environment variables 'SSL_KEYFILE' and 'SSL_CERTFILE'.",
)
args = parser.parse_args()
logger.info(f"args: {args}")

Expand All @@ -327,4 +335,14 @@ def create_controller():

if __name__ == "__main__":
args, controller = create_controller()
uvicorn.run(app, host=args.host, port=args.port, log_level="info")
if args.ssl:
uvicorn.run(
app,
host=args.host,
port=args.port,
log_level="info",
ssl_keyfile=os.environ["SSL_KEYFILE"],
ssl_certfile=os.environ["SSL_CERTFILE"]
)
else:
uvicorn.run(app, host=args.host, port=args.port, log_level="info")

0 comments on commit 68f1fac

Please sign in to comment.