@re-shell/cli
Version:
Full-stack development platform uniting microservices and microfrontends. Build complete applications with .NET (ASP.NET Core Web API, Minimal API), Java (Spring Boot, Quarkus, Micronaut, Vert.x), Rust (Actix-Web, Warp, Rocket, Axum), Python (FastAPI, Dja
84 lines (83 loc) • 2.06 kB
TypeScript
/**
* Resource management and cleanup utilities
*/
export declare class ResourceManager {
private static instance;
private resources;
private memoryMonitor?;
private cleanupInterval?;
private constructor();
static getInstance(): ResourceManager;
/**
* Register a resource for tracking and cleanup
*/
register(id: string, type: string, resource: any, cleanup: () => void | Promise<void>): void;
/**
* Unregister and cleanup a specific resource
*/
unregister(id: string): Promise<void>;
/**
* Get current memory usage
*/
getMemoryUsage(): NodeJS.MemoryUsage;
/**
* Get memory usage in human readable format
*/
getFormattedMemoryUsage(): string;
/**
* Force garbage collection if available
*/
forceGC(): void;
/**
* Check if memory usage is high
*/
isMemoryHigh(): boolean;
/**
* Get resource statistics
*/
getResourceStats(): {
total: number;
byType: Record<string, number>;
};
/**
* Cleanup old or unused resources
*/
cleanupOldResources(maxAge?: number): Promise<void>;
/**
* Cleanup all resources
*/
cleanup(): Promise<void>;
/**
* Setup event handlers for graceful shutdown
*/
private setupEventHandlers;
/**
* Start memory monitoring
*/
private startMemoryMonitoring;
/**
* Start periodic cleanup
*/
private startPeriodicCleanup;
}
export declare const resourceManager: ResourceManager;
/**
* Track a file watcher
*/
export declare function trackFileWatcher(id: string, watcher: any): void;
/**
* Track a timer
*/
export declare function trackTimer(id: string, timer: NodeJS.Timeout): void;
/**
* Track an interval
*/
export declare function trackInterval(id: string, interval: NodeJS.Timeout): void;
/**
* Track a process
*/
export declare function trackProcess(id: string, proc: any): void;
/**
* Track a server
*/
export declare function trackServer(id: string, server: any): void;