// Import the configuration file import { getConfig, NodeConnection } from "./helper/config"; // Import SystemControl import { SystemControl } from "./models/SystemController"; // Import the worker processes import { DataWorker } from "./models/WorkerProcess"; // Global system control singleton ((global as any).logger as SystemControl) = new SystemControl(); /** * The main function to run the program with */ async function main() { // Get the configuration file const config = getConfig(); // Initialize the Worker Nodes array let workerNodes : Array = []; // Spawn in the DataWorkers for ( let i: number = 0; i < config.options.parallel_nodes; i++ ) { // Create a new data worker workerNodes.push(new DataWorker(config.options.parallel_node_tasks)); } /** * Keep track of the worker that is assigned this node */ let workerIndex = 0; // Start assigning nodes to the DataWorkers for ( let node of config.nodes ) { console.log(`Adding workerIndex[${workerIndex}]`); // Add the task to the node workerNodes[workerIndex].addNodeTask(node); // Increment the worker index workerIndex++; if ( workerIndex >= workerNodes.length ) workerIndex = 0; } console.log(`Succesfully added ${config.nodes.length} Tasks to ${workerNodes.length} Workers`); for( let w of workerNodes ) { await w.startProcessing(); } } // Run the main program main();