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
+16 -14
View File
@@ -1,18 +1,20 @@
import { workerData, parentPort } from 'worker_threads';
import { BackupRetrievalWorker} from '../helpers/backup_retrieval'; // Assuming the class is in the same folder
import { BackupRetrievalWorker } from '../helpers/backup_retrieval';
import dotenv from 'dotenv';
// Destructure the data passed from the WorkerManager
const {
userConfigPath,
applicationInfoPath,
clientPort,
destinationPath
}: {
userConfigPath: string,
applicationInfoPath: string,
clientPort: number,
destinationPath: string
} = workerData;
// Load environment variables from .env file if it exists
dotenv.config();
// Retrieve configuration from environment variables
const userConfigPath = process.env.USER_CONFIG_PATH as string;
const applicationInfoPath = process.env.APPLICATION_INFO_PATH as string;
const clientPort = Number(process.env.CLIENT_PORT);
const destinationPath = process.env.DESTINATION_PATH as string;
// Validate that all required environment variables are present
if (!userConfigPath || !applicationInfoPath || !clientPort || !destinationPath) {
console.error('Error: Missing required environment variables.');
process.exit(1);
}
// Initialize the BackupRetrievalWorker
const backupRetrievalWorker = new BackupRetrievalWorker(