diff --git a/front/server/src/cli.ts b/front/server/src/cli.ts index f45b1d13..ae95043a 100644 --- a/front/server/src/cli.ts +++ b/front/server/src/cli.ts @@ -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); diff --git a/front/server/src/server.ts b/front/server/src/server.ts index 4610ed67..39350d47 100644 --- a/front/server/src/server.ts +++ b/front/server/src/server.ts @@ -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((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) { @@ -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((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) { @@ -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((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(); + }); }); } } \ No newline at end of file