Fix embedded-postgres PID file written before initialization
The PID file was written to the database directory before `pg.initialise()`, which prevented initialization from succeeding. Moved the PID file write to just after initialization but before starting the database. Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com> Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli-module-build': patch
|
||||
---
|
||||
|
||||
Fixed the embedded-postgres PID file being written before database initialization, which prevented the database from initializing successfully.
|
||||
@@ -78,8 +78,6 @@ export async function startEmbeddedDb() {
|
||||
const port = await getPortPromise();
|
||||
const tmpDir = await fs.mkdtemp(resolvePath(os.tmpdir(), TEMP_DIR_PREFIX));
|
||||
|
||||
await fs.writeFile(resolvePath(tmpDir, PID_FILE), String(process.pid));
|
||||
|
||||
const pg = new EmbeddedPostgres({
|
||||
databaseDir: tmpDir,
|
||||
user,
|
||||
@@ -94,6 +92,7 @@ export async function startEmbeddedDb() {
|
||||
|
||||
try {
|
||||
await pg.initialise();
|
||||
await fs.writeFile(resolvePath(tmpDir, PID_FILE), String(process.pid));
|
||||
await pg.start();
|
||||
} catch (error) {
|
||||
await pg.stop().catch(() => {});
|
||||
|
||||
Reference in New Issue
Block a user