How It Works
- A version spec such as
17is resolved against the versions published for the platform. The binaries for that version are downloaded from Maven once, checked against the SHA-256 Maven publishes next to them, and cached inBinariesDir. Each download is retried 3 times. An unknown version fails fast with a clear error. - The binaries, plus the configured extensions, are extracted once into a shared install folder in
BinariesDir, for examplepostgres-17.6.0-linux-amd64. Every instance with the same version and extensions reuses it, so later servers start in about a second. initdbcreates the instance'sdatafolder.- The port and
ServerParamsare written topg_embed.conf, which is included frompostgresql.conf. pg_ctl start -wstarts the server and waits until it accepts connections.- On stop,
pg_ctl stopruns in fast mode, falling back to immediate mode and then to killing the process.
Where things live
- An instance folder holds the
datafolder and the server log (server.LogFile): under<DbDir>/pg_embed, named afterInstanceId, or in the shared cache for a named instance. - Instances that are not named are deleted when the server stops (
ClearInstanceDirOnStop); named ones are kept. server.InstallDirandserver.PgBinDirpoint at the shared install,server.DataDirat the data.
