diff --git a/cortex-js/src/infrastructure/commanders/serve.command.ts b/cortex-js/src/infrastructure/commanders/serve.command.ts index 42bfbc6a1..468fc4de3 100644 --- a/cortex-js/src/infrastructure/commanders/serve.command.ts +++ b/cortex-js/src/infrastructure/commanders/serve.command.ts @@ -36,11 +36,15 @@ export class ServeCommand extends CommandRunner { private async startServer(host: string, port: number) { const app = await getApp(); - await app.listen(port, host); - console.log(chalk.blue(`Started server at http://${host}:${port}`)); - console.log( - chalk.blue(`API Playground available at http://${host}:${port}/api`), - ); + try { + await app.listen(port, host); + console.log(chalk.blue(`Started server at http://${host}:${port}`)); + console.log( + chalk.blue(`API Playground available at http://${host}:${port}/api`), + ); + } catch (err) { + console.error(err.message); + } } @Option({ diff --git a/cortex-js/src/main.ts b/cortex-js/src/main.ts index 217b84884..e54d8f10e 100644 --- a/cortex-js/src/main.ts +++ b/cortex-js/src/main.ts @@ -11,11 +11,15 @@ async function bootstrap() { const host = process.env.CORTEX_JS_HOST || defaultCortexJsHost; const port = process.env.CORTEX_JS_PORT || defaultCortexJsPort; - await app.listen(port, host); - console.log(chalk.blue(`Started server at http://${host}:${port}`)); - console.log( - chalk.blue(`API Playground available at http://${host}:${port}/api`), - ); + try { + await app.listen(port, host); + console.log(chalk.blue(`Started server at http://${host}:${port}`)); + console.log( + chalk.blue(`API Playground available at http://${host}:${port}/api`), + ); + } catch (err) { + console.error(err.message); + } } bootstrap();