Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/cli/src/actions/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@ function startServer(client: ClientContract<any, any>, schema: any, options: Opt
console.log(`You can visit ZenStack Studio at: ${colors.blue('https://studio.zenstack.dev')}`);
});

server.on('error', (err: NodeJS.ErrnoException) => {
if (err.code === 'EADDRINUSE') {
console.error(
colors.red(`Port ${options.port} is already in use. Please choose a different port using -p option.`),
);
} else {
throw new CliError(`Failed to start the server: ${err.message}`);
}
process.exit(1);
});

// Graceful shutdown
process.on('SIGTERM', async () => {
server.close(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Arguments following -- are passed to the seed script. E.g.: "zen db seed -- --us
.alias('studio')
.description('Start the ZenStack proxy server')
.addOption(schemaOption)
.addOption(new Option('-p, --port <port>', 'port to run the proxy server on').default(8008))
.addOption(new Option('-p, --port <port>', 'port to run the proxy server on').default(2311))
.addOption(new Option('-o, --output <path>', 'output directory for `zen generate` command'))
.addOption(new Option('-d, --databaseUrl <url>', 'database connection URL'))
.addOption(new Option('-l, --logLevel <level>', 'Query log levels (e.g., query, error)'))
Expand Down