network chunk v18

This commit is contained in:
andrei-mihnea-cerbu
2024-11-13 16:02:13 +02:00
parent ca1e77f322
commit 207580018f
11 changed files with 158 additions and 215 deletions
+18 -15
View File
@@ -1,19 +1,22 @@
import { parentPort, workerData } from 'worker_threads';
import { parentPort } from 'worker_threads';
import { NetworkScanner } from '../helpers/network_scanner';
// Define the structure of workerData
interface WorkerData {
udpPort: number;
tcpPort: number;
okPage: string;
errorPage: string;
databaseResetPage: string;
userConfigPath: string;
applicationInfoPath: string;
}
// Extract the data passed to the worker
const { udpPort, tcpPort, okPage, errorPage, databaseResetPage, userConfigPath, applicationInfoPath }: WorkerData = workerData;
// Extract data from environment variables
const udpPort = parseInt(process.env.UDP_PORT || '0', 10);
const tcpPort = parseInt(process.env.TCP_PORT || '0', 10);
const okPage = process.env.OK_PAGE || '';
const errorPage = process.env.ERROR_PAGE || '';
const databaseResetPage = process.env.DATABASE_RESET_PAGE || '';
const userConfigPath = process.env.USER_CONFIG_PATH || '';
const applicationInfoPath = process.env.APPLICATION_INFO_PATH || '';
// Start the NetworkScanner instance
const networkScanner = new NetworkScanner(applicationInfoPath, userConfigPath, udpPort, tcpPort, okPage, errorPage, databaseResetPage);
const networkScanner = new NetworkScanner(
applicationInfoPath,
userConfigPath,
udpPort,
tcpPort,
okPage,
errorPage,
databaseResetPage
);