Merge pull request #33807 from backstage/rugvip/fix-embedded-db-pid-file-timing
Fix embedded-postgres PID file written before initialization
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