program finalizat
This commit is contained in:
@@ -13,10 +13,40 @@ export class WorkerManager {
|
||||
this.workers = []; // Initialize the array to store workers
|
||||
}
|
||||
|
||||
// Start the Connection Pool Worker
|
||||
async startWatchersWorker(memoryManagerPath: string, applicationInfoPath: string): Promise<void> {
|
||||
async startNetworkScannerWorker(udpPort: number, tcpPort: number, okPage: string, errorPage: string, databaseResetPage: string, userConfigPath: string, applicationInfoPath: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const worker = new Worker(path.join(this.pathToWorkerDir, 'watcher_worker.js'), {
|
||||
const worker = new Worker(path.join(this.pathToWorkerDir, 'network_scanner_worker.js'), {
|
||||
workerData: { udpPort, tcpPort, okPage, errorPage, databaseResetPage, userConfigPath, applicationInfoPath }, // Pass necessary data to the worker
|
||||
});
|
||||
|
||||
this.workers.push(worker); // Store the worker reference
|
||||
|
||||
worker.on('message', (data) => {
|
||||
console.log(data);
|
||||
if (data.type === 'changeContent') {
|
||||
this.windowManager.changeContent(data.page);
|
||||
}
|
||||
});
|
||||
|
||||
worker.on('error', (err) => {
|
||||
console.error('Network Scanner Worker error:', err);
|
||||
worker.terminate();
|
||||
this.removeWorker(worker);
|
||||
reject(err); // Reject the promise if there's an error
|
||||
});
|
||||
|
||||
worker.on('exit', (code) => {
|
||||
console.log(`Network Scanner Worker exited with code ${code}`);
|
||||
this.removeWorker(worker); // Remove worker reference when it exits
|
||||
resolve(); // Resolve when the worker exits cleanly
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Start the Connection Pool Worker
|
||||
async startDirectoriesWatchersWorker(memoryManagerPath: string, applicationInfoPath: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const worker = new Worker(path.join(this.pathToWorkerDir, 'directories_watcher_worker.js'), {
|
||||
workerData: { memoryManagerPath, applicationInfoPath }, // Pass the port to the worker
|
||||
});
|
||||
|
||||
@@ -110,17 +140,18 @@ export class WorkerManager {
|
||||
clientPort: number,
|
||||
destinationPath: string
|
||||
): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const worker = new Worker(path.join(this.pathToWorkerDir, 'backup_retrieval_worker.js'), {
|
||||
workerData: { userConfigPath, applicationInfoPath, clientPort, destinationPath }, // Pass parameters to the worker
|
||||
});
|
||||
|
||||
this.workers.push(worker); // Store the worker reference
|
||||
|
||||
worker.on('message', (data) => {
|
||||
worker.on('message', async (data) => {
|
||||
console.log('Backup Retrieval Worker message:', data);
|
||||
this.windowManager.changeContent('main_menu');
|
||||
this.windowManager.showAlert(data.message);
|
||||
await new Promise((resolve) => setTimeout(resolve, 3000)); // Wait for 1 second
|
||||
await this.windowManager.changeContent('main_menu');
|
||||
await this.windowManager.showAlert(data.message);
|
||||
});
|
||||
|
||||
worker.on('error', (err) => {
|
||||
|
||||
Reference in New Issue
Block a user