Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow changing the port with --port flag #210

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions backend/openui/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def is_running_in_docker():
or "OPENUI_LITELLM_CONFIG" in os.environ
or os.path.exists("litellm-config.yaml")
)
# allow setting the port with --port
port = (
int(sys.argv[sys.argv.index("--port") + 1])
if "--port" in sys.argv and len(sys.argv) > sys.argv.index("--port") + 1
else None
) or int(os.environ.get("PORT", 7878))
# TODO: only render in interactive mode?
print(
(Path(__file__).parent / "logo.ascii").read_text(), file=sys.stderr, flush=True
Expand Down Expand Up @@ -68,7 +74,7 @@ def is_running_in_docker():
"openui.server:app",
host="0.0.0.0" if is_running_in_docker() else "127.0.0.1",
log_config=str(config_file) if ui else None,
port=7878,
port=port,
reload=reload,
)
)
Expand Down Expand Up @@ -111,7 +117,7 @@ def is_running_in_docker():
uvicorn.run(
"openui.server:app",
host="0.0.0.0" if is_running_in_docker() else "127.0.0.1",
port=7878,
port=port,
reload=reload,
)
else:
Expand Down