Skip to content

Commit

Permalink
chore: cortex serve error handling - port conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Jun 26, 2024
1 parent 185f9b6 commit 4d60260
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions cortex-js/src/infrastructure/commanders/serve.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
14 changes: 9 additions & 5 deletions cortex-js/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

0 comments on commit 4d60260

Please sign in to comment.