Add PostgreSQL-backed background worker
This commit is contained in:
+8
-9
@@ -145,15 +145,14 @@ App listens on `${WEB_PORT:-${PORT:-3000}}` on the host (container port is alway
|
||||
|
||||
### Scheduled recurring invoices
|
||||
|
||||
The app container does not run a cron daemon. It starts the web server with
|
||||
`bun migrate.ts && bun run start`, and recurring invoice generation only happens
|
||||
when something calls `POST /api/cron/generate-recurring` with
|
||||
`Authorization: Bearer $CRON_SECRET`.
|
||||
The Compose stack includes a dedicated PostgreSQL-backed worker. It discovers due
|
||||
recurring invoices every minute, enqueues idempotent jobs, and processes them with
|
||||
bounded retries and stale-lock recovery. No Coolify scheduled task or Redis
|
||||
service is required.
|
||||
|
||||
- **Coolify deploys:** use a Coolify scheduled task to call the endpoint.
|
||||
- **Full Docker deploys:** use host cron, a small scheduler sidecar, or an
|
||||
external scheduler to call
|
||||
`http://localhost:${WEB_PORT:-${PORT:-3000}}/api/cron/generate-recurring`.
|
||||
`POST /api/cron/generate-recurring` remains available as an optional authenticated
|
||||
"schedule now" hook. It only enqueues due work; invoice generation stays in the
|
||||
worker.
|
||||
|
||||
### 3. Updating an existing deploy
|
||||
|
||||
@@ -170,7 +169,7 @@ git pull
|
||||
| `../../scripts/docker-deploy.sh` or root `docker compose up -d --build` | Yes | Yes — on app container start |
|
||||
| `docker compose restart app` | No | Yes — migrate runs again (no-op if up to date) |
|
||||
|
||||
Prune old app images occasionally: `docker image prune -f` (or remove specific `beenvoice:*` tags).
|
||||
Prune old app and worker images occasionally: `docker image prune -f` (or remove specific `beenvoice:*` / `beenvoice-worker:*` tags).
|
||||
|
||||
To verify migration files match the journal before deploy: `bun run db:verify-journal`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user