Repository navigation
pgx run — one command to a ready database (stacked on #2) - #4
Merged
Merged
Conversation
pgx run initialises $PGX_HOME if needed, starts the runtime if it is not already up, ensures a default `app` database, and prints its connection URL. Every step is idempotent and safe to repeat; it never resets or overwrites an existing database. A run-level flock serialises concurrent invocations so a fresh first run cannot race in init, and --json emits a single object for agents. Secure localhost-only defaults are inherited from init (loopback, scram-sha-256, random password). Refactors start into a non-emitting ensure_running returning a StartOutcome so run reports the whole operation once; adds Out::quiet() for composite commands. start/restart behaviour is unchanged (existing lifecycle tests stay green). Tests (tests/run.rs, against the assembled distribution): fresh install, idempotency with no duplicates, persistence across restart, existing databases untouched, localhost-only + password-protected defaults, 8-way concurrent runs (one engine, one app), and recovery after an engine crash. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add --test run to the black-box CI step so tests/run.rs runs on every PR. Document `pgx run` as the one-command quick start in the CLI reference and the install guide (curl … | sh, then pgx run). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The container ran as root, and the PGX engine (like PostgreSQL) refuses "root execution of the PostgreSQL server" — so `pgx serve` exited status 1 and the container never accepted TCP. Add an unprivileged `pgx` user, own the data/run dirs, COPY the distribution --chown=pgx (so the bundled base cluster, mode 700, is readable), and USER pgx. The named volume inherits pgx ownership. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The ETXTBSY retry was only on run(); run_cmd/spawn_run (used by the pgx run suite) still panicked on a transient 'Text file busy' exec of the freshly copied binary under CI parallelism. Route all three spawn paths through one output_retrying helper (and retry spawn_run's spawn). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pgx run— one command to a ready databaseStacked on #2. The developer onboarding the public install promises:
curl -fsSL https://pgx.dev/install | sh pgx runpgx runinitialises$PGX_HOMEif needed, starts the runtime if it is not already up, ensures a defaultappdatabase, and prints its connection URL. Every step is idempotent and safe to repeat; it never resets or overwrites an existing database.Behaviour
pgx runreportsapp (existing)/runtime already runningand does not restart or duplicate anything.flockserialises concurrent invocations, so even a first run from several processes at once cannot race ininit; one engine starts, oneappis created.--jsonemits a single object (ready,url,database,database_created,started,already_running,pid,port, …) for agents.init: loopbacklisten_addresses,scram-sha-256over TCP, a random password. The first run honoursPGX_PORT/PGX_DURABILITY/PGX_PASSWORD.crates/bin/pgx;start/restartbehaviour is unchanged (existing lifecycle tests stay green).Tests (all green locally against the assembled distribution)
tests/run.rs(8): fresh install → ready; idempotent, no duplicates; persistence across restart; existing databases untouched; localhost-only + password-protected; 8-way concurrent runs (one engine, oneapp); recovery after an engine crash.Also contains a CI fix (inherited from #2): the
Unit testsstep is scoped to--bin pgxso it no longer pulls in the dist-dependent integration suites, and therunsuite is added to the black-box step.🤖 Generated with Claude Code