Explain the SSL failure instead of just reporting it

A Postgres URL without an sslmode made lib/pq ask for TLS and die with
"SSL is not enabled on the server", which reads like a server fault when
it is really a connection-string default. The error now says what to
append, and the server retries briefly so a deploy is not marked
unhealthy just because Postgres was still starting.

The sync server URL also defaults to the hosted instance now, so a fresh
install needs no setup.
This commit is contained in:
2026-10-08 10:38:54 +08:00
parent c0dd211ee5
commit 1bd346ce20
5 changed files with 76 additions and 14 deletions
+25 -1
View File
@@ -26,7 +26,31 @@ PROMPT_SYNC_DATABASE_URL="postgres://localhost:5432/prompt_sync?sslmode=disable"
The schema is created on startup. Every request is logged as
`METHOD PATH STATUS DURATION`; SIGTERM/SIGINT shut down gracefully so an
in-flight push is not cut off mid-write.
in-flight push is not cut off mid-write. If the database is not reachable yet
it retries five times, 2s apart, before giving up.
> **`sslmode` matters.** lib/pq defaults to `sslmode=require`, so a connection
> string copied from a host that runs Postgres *without* TLS (Coolify's
> internal Postgres, a plain `docker run postgres`, Homebrew) fails with
> `pq: SSL is not enabled on the server`. Append `?sslmode=disable` in that
> case — the server prints exactly that hint when it hits this.
## Deploying with Coolify
Use a Dockerfile application pointed at this repo with base directory `Server/`
(so Coolify builds `Server/Dockerfile`), expose port `8080`, and set:
| Variable | Value |
| --- | --- |
| `PROMPT_SYNC_DATABASE_URL` | your Postgres URL **plus `?sslmode=disable`** |
| `PROMPT_SYNC_ADDR` | `:8080` (this is already the default) |
Coolify detects the `HEALTHCHECK` in the Dockerfile and runs
`prompt-sync -healthcheck` with its 5s start period, so the container only goes
live once `/healthz` answers. It also logs a generic warning that a healthcheck
needs `curl` or `wget` — that does not apply here, the binary does its own
check, so there is no reason to add either to the image (it is distroless and
has no shell).
## Run with Docker