Skip to content

Commit

Permalink
feat: add pm2 front process.send ready (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiroaisen authored Jun 14, 2023
2 parents a1ec7b9 + 72cc27b commit dd9804b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
4 changes: 3 additions & 1 deletion front/server/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ const start = async (opts: { config: string }) => {
process.exit(1);
}

app.start({ config: conf, logger });
await app.start({ config: conf, logger });

if(process.send) process.send("ready");
}

cmd.version(VERSION);
Expand Down
28 changes: 20 additions & 8 deletions front/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ export const start = async ({ config, logger }: { config: Config, logger: Logger
app.use(kit(handler));
}

app.listen(config.studio.port, () => {
logger.scoped("start").info(`studio server bound to port ${color.yellow(config.studio!.port)}`);
});
await new Promise<void>((resolve, reject) => {
app.listen(config.studio!.port, (...args: any[]) => {
if(args[0]) return reject(args[0])
logger.scoped("start").info(`studio server bound to port ${color.yellow(config.studio!.port)}`);
resolve();
});
})
}

if(config.admin?.enabled) {
Expand All @@ -53,9 +57,13 @@ export const start = async ({ config, logger }: { config: Config, logger: Logger
app.use(kit(handler));
}

app.listen(config.admin.port, () => {
logger.scoped("start").info(`admin server bound to port ${color.yellow(config.admin!.port)}`);
});
await new Promise<void>((resolve, reject) => {
app.listen(config.admin!.port, (...args: any[]) => {
if(args[0]) return reject(args[0])
logger.scoped("start").info(`admin server bound to port ${color.yellow(config.admin!.port)}`);
resolve();
});
})
}

if(config.payments?.enabled) {
Expand All @@ -64,8 +72,12 @@ export const start = async ({ config, logger }: { config: Config, logger: Logger

app.use(payments_api({ config: config.payments, logger }))

app.listen(config.payments.port, () => {
logger.scoped("start").info(`payments server bound to port ${color.yellow(config.payments!.port)}`);
await new Promise<void>((resolve, reject) => {
app.listen(config.payments!.port, (...args: any[]) => {
if(args[0]) return reject(args[0])
logger.scoped("start").info(`payments server bound to port ${color.yellow(config.payments!.port)}`);
resolve();
});
});
}
}

0 comments on commit dd9804b

Please sign in to comment.