Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions PlanExe.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
},
{
"path": "mcp_local"
},
{
"path": "database_worker"
},
{
"path": "llm_config"
}
],
"settings": {
Expand Down
14 changes: 7 additions & 7 deletions database_worker/railway.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ This service provides database backup (via `pg_dump`) and is called by `frontend
## Service variables example

```
PGHOST="${{shared.PLANEXE_POSTGRES_HOST}}"
PGPORT="5432"
PGDATABASE="planexe"
PGUSER="planexe"
PGPASSWORD="${{shared.PLANEXE_POSTGRES_PASSWORD}}"
PLANEXE_POSTGRES_HOST="${{shared.PLANEXE_POSTGRES_HOST}}"
PLANEXE_POSTGRES_PORT="5432"
PLANEXE_POSTGRES_DB="planexe"
PLANEXE_POSTGRES_USER="planexe"
PLANEXE_POSTGRES_PASSWORD="${{shared.PLANEXE_POSTGRES_PASSWORD}}"
PLANEXE_DATABASE_WORKER_API_KEY="${{shared.PLANEXE_DATABASE_WORKER_API_KEY}}"
```

## Required Environment Variables

- `PGHOST` — Postgres host. On Railway, use the internal hostname (e.g. `postgres.railway.internal`). The Docker Compose default `database_postgres` does not resolve on Railway.
- `PGPASSWORD` — Postgres password.
- `PLANEXE_POSTGRES_HOST` — Postgres host. On Railway, use the internal hostname (e.g. `postgres.railway.internal`). The Docker Compose default `database_postgres` does not resolve on Railway.
- `PLANEXE_POSTGRES_PASSWORD` — Postgres password.

## Optional Environment Variables

Expand Down
20 changes: 10 additions & 10 deletions database_worker/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
logger = logging.getLogger(__name__)

PGHOST = os.environ.get("PGHOST", "database_postgres")
PGPORT = os.environ.get("PGPORT", "5432")
PGDATABASE = os.environ.get("PGDATABASE", "planexe")
PGUSER = os.environ.get("PGUSER", "planexe")
PGPASSWORD = os.environ.get("PGPASSWORD", "planexe")
POSTGRES_HOST = os.environ.get("PLANEXE_POSTGRES_HOST", "database_postgres")
POSTGRES_PORT = os.environ.get("PLANEXE_POSTGRES_PORT", "5432")
POSTGRES_DB = os.environ.get("PLANEXE_POSTGRES_DB", "planexe")
POSTGRES_USER = os.environ.get("PLANEXE_POSTGRES_USER", "planexe")
POSTGRES_PASSWORD = os.environ.get("PLANEXE_POSTGRES_PASSWORD", "planexe")
API_KEY = os.environ.get("PLANEXE_DATABASE_WORKER_API_KEY", "")
# Railway injects PORT; fall back to PLANEXE_DATABASE_WORKER_PORT for Docker Compose.
PORT = int(os.environ.get("PORT") or os.environ.get("PLANEXE_DATABASE_WORKER_PORT", "8002"))
Expand Down Expand Up @@ -66,15 +66,15 @@ def do_GET(self):
logger.info("Starting database backup: %s (%s)", filename, "zstd" if _HAS_ZSTD else "gzip")

env = os.environ.copy()
env["PGPASSWORD"] = PGPASSWORD
env["PGPASSWORD"] = POSTGRES_PASSWORD # pg_dump reads PGPASSWORD from env

proc = subprocess.Popen(
[
"pg_dump",
"-h", PGHOST,
"-p", PGPORT,
"-U", PGUSER,
"-d", PGDATABASE,
"-h", POSTGRES_HOST,
"-p", POSTGRES_PORT,
"-U", POSTGRES_USER,
"-d", POSTGRES_DB,
"--no-owner",
"--no-privileges",
"-Z", compress_flag,
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ services:
database_postgres:
condition: service_healthy
environment:
PGHOST: database_postgres
PGPORT: "5432"
PGDATABASE: ${PLANEXE_POSTGRES_DB:-planexe}
PGUSER: ${PLANEXE_POSTGRES_USER:-planexe}
PGPASSWORD: ${PLANEXE_POSTGRES_PASSWORD:-planexe}
PLANEXE_POSTGRES_HOST: database_postgres
PLANEXE_POSTGRES_PORT: "5432"
PLANEXE_POSTGRES_DB: ${PLANEXE_POSTGRES_DB:-planexe}
PLANEXE_POSTGRES_USER: ${PLANEXE_POSTGRES_USER:-planexe}
PLANEXE_POSTGRES_PASSWORD: ${PLANEXE_POSTGRES_PASSWORD:-planexe}
PLANEXE_DATABASE_WORKER_API_KEY: ${PLANEXE_DATABASE_WORKER_API_KEY:-}
restart: unless-stopped

Expand Down
Loading