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
4 changes: 3 additions & 1 deletion genkit-tools/cli/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface StartOptions {
headless?: boolean;
port: string;
attach?: string;
open?: boolean;
}

/** Command to start GenKit server, optionally without static file serving */
Expand All @@ -35,6 +36,7 @@ export const start = new Command('start')
false
)
.option('-p, --port <number>', 'Port to serve on. Default is 4000', '4000')
.option('-o, --open', 'Open the browser with the Developer UI')
.option(
'-a, --attach <number>',
'Externally running dev process address to attach to'
Expand All @@ -57,5 +59,5 @@ export const start = new Command('start')
} else {
await runner.start();
}
return startServer(runner, options.headless ?? false, port);
return startServer(runner, options.headless ?? false, port, !!options.open);
});
7 changes: 5 additions & 2 deletions genkit-tools/common/src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const API_BASE_PATH = '/api';
export function startServer(
runner: Runner,
headless: boolean,
port: number
port: number,
openBrowser: boolean
): Promise<void> {
let serverEnder: (() => void) | undefined = undefined;
const enderPromise = new Promise<void>((resolver) => {
Expand Down Expand Up @@ -133,7 +134,9 @@ export function startServer(
.waitUntilHealthy()
.then(() => {
logger.info(`${clc.green(clc.bold('Genkit Tools UI:'))} ${uiUrl}`);
open(uiUrl);
if (openBrowser) {
open(uiUrl);
}
})
.catch((e) => {
logger.error(e.message);
Expand Down