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

feat(server): REST API and WS API now use env vars for host and port. #8057

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
9 changes: 9 additions & 0 deletions rnd/autogpt_server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ REDIS_PASSWORD=password
ENABLE_AUTH=false
ENABLE_CREDIT=false
APP_ENV="local"

# REST API
AP_SERVER_HOST="0.0.0.0"
AP_SERVER_PORT="8000"

# WS API
WS_SERVER_HOST="0.0.0.0"
WS_SERVER_PORT="8001"
Comment on lines +17 to +22
Copy link
Contributor

@kcze kcze Sep 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit for consistency

Suggested change
AP_SERVER_HOST="0.0.0.0"
AP_SERVER_PORT="8000"
# WS API
WS_SERVER_HOST="0.0.0.0"
WS_SERVER_PORT="8001"
AP_SERVER_HOST=localhost
AP_SERVER_PORT=8000
# WS API
WS_SERVER_HOST=localhost
WS_SERVER_PORT=8001

edit: I realised that 0.0.0.0 is not the same as localhost but quote marks can be removed nonetheless.


PYRO_HOST=localhost
SENTRY_DSN=

Expand Down
1 change: 1 addition & 0 deletions rnd/autogpt_server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ FROM server_dependencies AS server

COPY rnd/autogpt_server /app/rnd/autogpt_server

ENV AP_SERVER_PORT=8000
ENV DATABASE_URL=""
ENV PORT=8000

Expand Down
8 changes: 7 additions & 1 deletion rnd/autogpt_server/autogpt_server/server/rest_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import inspect
import os
from collections import defaultdict
from contextlib import asynccontextmanager
from functools import wraps
Expand Down Expand Up @@ -219,7 +220,12 @@ def run_service(self):

app.include_router(api_router)

uvicorn.run(app, host="0.0.0.0", port=8000, log_config=None)
uvicorn.run(
app,
host=os.getenv("AP_SERVER_HOST", "0.0.0.0"),
port=int(os.getenv("AP_SERVER_PORT", "8000")),
log_config=None,
)

def set_test_dependency_overrides(self, overrides: dict):
self._test_dependency_overrides = overrides
Expand Down
Loading