Skip to content

Commit 4a25d16

Browse files
committed
start postgres db first
1 parent 6c6cf27 commit 4a25d16

File tree

1 file changed

+34
-32
lines changed

1 file changed

+34
-32
lines changed

test/util/netLaunch/index.ts

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,39 @@ export class NetworkLauncher {
381381
console.log(`[NetworkLauncher] toxiproxy service started`);
382382
}
383383

384+
// Postgres is always needed for fullnet because MSPs require database access
385+
// For other network types, only start postgres if indexer is enabled
386+
if (this.type === "fullnet" || this.config.indexer) {
387+
console.log(`[NetworkLauncher] Starting sh-postgres service...`);
388+
await compose.upOne("sh-postgres", {
389+
cwd: cwd,
390+
config: tmpFile,
391+
log: verbose
392+
});
393+
console.log(`[NetworkLauncher] sh-postgres service started`);
394+
395+
// Only run external migrations when indexer enabled
396+
// (MSPs and standalone indexer auto-migrate themselves)
397+
if (this.type === "fullnet" || this.config.indexer) {
398+
await this.runMigrations();
399+
}
400+
401+
// Start backend only if backend flag is enabled (depends on msp-1 and postgres)
402+
if (this.config.backend && this.type === "fullnet") {
403+
console.log(`[NetworkLauncher] Starting sh-backend service...`);
404+
await compose.upOne("sh-backend", {
405+
cwd: cwd,
406+
config: tmpFile,
407+
log: verbose,
408+
env: {
409+
...process.env,
410+
JWT_SECRET: JWT_SECRET
411+
}
412+
});
413+
console.log(`[NetworkLauncher] sh-backend service started`);
414+
}
415+
}
416+
384417
console.log(`[NetworkLauncher] Starting sh-bsp service...`);
385418
await compose.upOne("sh-bsp", {
386419
cwd: cwd,
@@ -455,38 +488,7 @@ export class NetworkLauncher {
455488
console.log(`[NetworkLauncher] All MSP services started`);
456489
}
457490

458-
// Postgres is always needed for fullnet because MSPs require database access
459-
// For other network types, only start postgres if indexer is enabled
460-
if (this.type === "fullnet" || this.config.indexer) {
461-
console.log(`[NetworkLauncher] Starting sh-postgres service...`);
462-
await compose.upOne("sh-postgres", {
463-
cwd: cwd,
464-
config: tmpFile,
465-
log: verbose
466-
});
467-
console.log(`[NetworkLauncher] sh-postgres service started`);
468-
469-
// Only run external migrations when indexer enabled
470-
// (MSPs and standalone indexer auto-migrate themselves)
471-
if (this.type === "fullnet" || this.config.indexer) {
472-
await this.runMigrations();
473-
}
474-
475-
// Start backend only if backend flag is enabled (depends on msp-1 and postgres)
476-
if (this.config.backend && this.type === "fullnet") {
477-
console.log(`[NetworkLauncher] Starting sh-backend service...`);
478-
await compose.upOne("sh-backend", {
479-
cwd: cwd,
480-
config: tmpFile,
481-
log: verbose,
482-
env: {
483-
...process.env,
484-
JWT_SECRET: JWT_SECRET
485-
}
486-
});
487-
console.log(`[NetworkLauncher] sh-backend service started`);
488-
}
489-
}
491+
490492

491493
console.log(`[NetworkLauncher] Starting sh-user service...`);
492494
await compose.upOne("sh-user", {

0 commit comments

Comments
 (0)