A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.
import { ChildProcess } from 'child_process';
import { killProcessTree } from '../utils/processTree';
export class ProcessManager {
private processes = new Map<string, ChildProcess>();
trackProcess(id: string, process: ChildProcess) {
this.processes.set(id, process);
}
killProcess(id: string) {
const process = this.processes.get(id);
if (process) {
killProcessTree(process, 'SIGTERM');
this.processes.delete(id);
return true;
}
return false;
}
killAll() {
for (const process of this.processes.values()) {
killProcessTree(process, 'SIGTERM');
}
this.processes.clear();
}
getProcess(id: string) {
return this.processes.get(id);
}
}
// Create a single instance to be used across the application
export const processManager = new ProcessManager();