Skip to content
Open
Changes from 3 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
21 changes: 13 additions & 8 deletions js/genkit/src/genkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,14 +782,19 @@ export function genkit(options: GenkitOptions): Genkit {
return new Genkit(options);
}

const shutdown = async () => {
logger.debug('Shutting down all Genkit servers...');
await ReflectionServer.stopAll();
process.exit(0);
Comment thread
pavelgj marked this conversation as resolved.
};

process.on('SIGTERM', shutdown);
process.on('SIGINT', shutdown);
// In development, we want to ensure that pressing Ctrl+C shuts down all reflection servers
// and exits immediately. In production, we do not register signal handlers to avoid
// overriding default Node.js behavior and breaking the host application's graceful shutdown.
if (isDevEnv()) {
const shutdown = async () => {
logger.debug('Shutting down all Genkit servers...');
await ReflectionServer.stopAll();
process.exit(0);
};
Comment thread
pavelgj marked this conversation as resolved.

process.on('SIGTERM', shutdown);
process.on('SIGINT', shutdown);
}

let disableReflectionApi = false;

Expand Down
Loading