Make the app's port configurable via DEVPLACE_PORT
make dev/prod hardcoded uvicorn to port 10500 with no way to override it, so config.PORT (and everything derived from it - INTERNAL_BASE_URL, Devii's own base URL defaults) stayed 10500 regardless of what port the process actually bound to. DEVPLACE_PORT now drives all of it, defaulting to 10500. Docker's existing PORT var (the externally published port via nginx) is unrelated and untouched; its app container pins DEVPLACE_PORT to 10500 explicitly so a bare-metal .env value can never leak in and desync it from the Dockerfile's fixed internal bind port. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -45,7 +45,7 @@ SECRET_KEY = environ.get("SECRET_KEY", "devplace-secret-key-change-in-production
|
||||
SECONDS_PER_DAY = 86400
|
||||
SESSION_MAX_AGE = SECONDS_PER_DAY * 7
|
||||
SESSION_MAX_AGE_REMEMBER = SECONDS_PER_DAY * 30
|
||||
PORT = 10500
|
||||
PORT = int(environ.get("DEVPLACE_PORT", "10500"))
|
||||
SITE_URL = environ.get("DEVPLACE_SITE_URL", "").rstrip("/")
|
||||
|
||||
PRESENCE_TIMEOUT_SECONDS = int(environ.get("DEVPLACE_PRESENCE_TIMEOUT_SECONDS", "60"))
|
||||
|
||||
@@ -11,12 +11,13 @@ from devplacepy.config import (
|
||||
INTERNAL_MODEL,
|
||||
DEVII_TASKS_DB,
|
||||
DEVII_LESSONS_DB,
|
||||
PORT,
|
||||
)
|
||||
|
||||
|
||||
DEFAULT_AI_URL = INTERNAL_GATEWAY_URL
|
||||
DEFAULT_AI_MODEL = INTERNAL_MODEL
|
||||
DEFAULT_BASE_URL = "http://127.0.0.1:10500"
|
||||
DEFAULT_BASE_URL = f"http://127.0.0.1:{PORT}"
|
||||
CONTEXT_WINDOW_TOKENS = 1_048_576
|
||||
MAX_OUTPUT_TOKENS = 384_000
|
||||
SYSTEM_RESERVE_TOKENS = 64_000
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
from devplacepy.config import PORT
|
||||
from devplacepy.services.base import BaseService, ConfigField
|
||||
|
||||
from . import config
|
||||
@@ -18,7 +19,7 @@ from .tasks.scheduler import GlobalScheduler, retire
|
||||
|
||||
logger = logging.getLogger("devii.service")
|
||||
|
||||
INSTANCE_ORIGIN_DEFAULT = "http://127.0.0.1:10500"
|
||||
INSTANCE_ORIGIN_DEFAULT = f"http://127.0.0.1:{PORT}"
|
||||
|
||||
|
||||
class DeviiService(BaseService):
|
||||
|
||||
@@ -118,7 +118,7 @@ The gateway records one row per upstream call (chat, vision, passthrough) and su
|
||||
|
||||
The gateway is the only place that holds real provider URLs/models/keys. Every other AI consumer (news, bots, Devii guests) points at it by default and never touches a provider key:
|
||||
|
||||
- Defaults live in `config.py`: `INTERNAL_GATEWAY_URL` (`http://localhost:10500/openai/v1/chat/completions`, override with `DEVPLACE_INTERNAL_BASE_URL`) and `INTERNAL_MODEL` (`molodetz`). `news_ai_url`, `bot_api_url`, `devii_ai_url` default to `INTERNAL_GATEWAY_URL`; their model defaults to `molodetz`.
|
||||
- Defaults live in `config.py`: `INTERNAL_GATEWAY_URL` (`http://localhost:{DEVPLACE_PORT, default 10500}/openai/v1/chat/completions`; the whole base can also be overridden with `DEVPLACE_INTERNAL_BASE_URL`) and `INTERNAL_MODEL` (`molodetz`). `news_ai_url`, `bot_api_url`, `devii_ai_url` default to `INTERNAL_GATEWAY_URL`; their model defaults to `molodetz`.
|
||||
- Each consumer's key falls back to `database.internal_gateway_key()` (reads the `gateway_internal_key` setting) when its own key field/env is unset - the provider-key fallbacks (`DEEPSEEK_API_KEY`/`OPENROUTER_API_KEY`) were removed from news and bots.
|
||||
- `gateway_force_model` (default on) and a `molodetz`/empty alias in `handle_chat` make the upstream always receive `gateway_model`, so `molodetz` is a stable generic alias.
|
||||
- `database.migrate_ai_gateway_settings()` (called at the end of `init_db()`, under the startup `init_lock`): generates `gateway_internal_key` (uuid4) if missing; migrates `DEEPSEEK_API_KEY`/`OPENROUTER_API_KEY` env into `gateway_api_key`/`gateway_vision_key` when the db value is empty; and rewrites any consumer AI URL still equal to the old `openai.app.molodetz.nl` default to the gateway, plus `bot_model` `deepseek-chat` -> `molodetz` (only uncustomized values).
|
||||
|
||||
Reference in New Issue
Block a user