finished shutdown lib
This commit is contained in:
parent
97dcd30223
commit
13c2f10db9
4 changed files with 213 additions and 28 deletions
|
|
@ -1,25 +1,25 @@
|
|||
/**
|
||||
* @stock-bot/shutdown - Graceful shutdown management library
|
||||
* @stock-bot/shutdown - Shutdown management library
|
||||
*
|
||||
* Main exports for the shutdown library
|
||||
*/
|
||||
|
||||
// Core shutdown classes and types
|
||||
export { GracefulShutdown } from './graceful-shutdown.js';
|
||||
export { Shutdown } from './shutdown.js';
|
||||
export type { ShutdownCallback, ShutdownOptions, ShutdownResult } from './types.js';
|
||||
|
||||
import { GracefulShutdown } from './graceful-shutdown.js';
|
||||
import { Shutdown } from './shutdown.js';
|
||||
import type { ShutdownResult } from './types.js';
|
||||
|
||||
// Global singleton instance
|
||||
let globalInstance: GracefulShutdown | null = null;
|
||||
let globalInstance: Shutdown | null = null;
|
||||
|
||||
/**
|
||||
* Get the global shutdown instance (creates one if it doesn't exist)
|
||||
*/
|
||||
function getGlobalInstance(): GracefulShutdown {
|
||||
function getGlobalInstance(): Shutdown {
|
||||
if (!globalInstance) {
|
||||
globalInstance = GracefulShutdown.getInstance();
|
||||
globalInstance = Shutdown.getInstance();
|
||||
}
|
||||
return globalInstance;
|
||||
}
|
||||
|
|
@ -42,13 +42,6 @@ export function setShutdownTimeout(timeout: number): void {
|
|||
getGlobalInstance().setTimeout(timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable debug logging
|
||||
*/
|
||||
export function setShutdownDebug(enabled: boolean): void {
|
||||
getGlobalInstance().setDebug(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if shutdown is currently in progress
|
||||
*/
|
||||
|
|
@ -82,5 +75,5 @@ export function shutdownAndExit(signal?: string, exitCode = 0): Promise<never> {
|
|||
*/
|
||||
export function resetShutdown(): void {
|
||||
globalInstance = null;
|
||||
GracefulShutdown.reset();
|
||||
Shutdown.reset();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue