first commit

This commit is contained in:
Giancarmine Salucci
2025-04-15 10:53:28 +02:00
commit d6365855b6
6 changed files with 500 additions and 0 deletions

33
main.js Normal file
View File

@@ -0,0 +1,33 @@
const {workerFactory, onMessage, onError, onExit} = require('./util');
const THREAD_COUNT = 4; // Number of threads you want to run
const data = {
url: 'https://care.drmax.eu/it/pharmacy/698Edb',
body: '__VIEWSTATE=%2FwEPDwULLTE5MzAwNTM5OTlkZJTEOkK8qrP%2BTqGLIsu2BOyqAooELsVS8rKLByxL86Wb&__VIEWSTATEGENERATOR=221C5153&cpt=Care&lang=it&type=698Edb&votes=Odeslat',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Origin': 'https://care.drmax.eu/it/pharmacies'
},
run: true
};
const workers = [...Array(THREAD_COUNT).keys()].map((id) => workerFactory(
{ id, ...data },
onMessage,
onError,
onExit
));
console.log(`main\t✅ Initialized ${workers.length} workers.`);
// Handle Ctrl+C
process.on('SIGINT', async () => {
console.log('\nmain\t🛑 Terminating workers...');
// Gracefully terminate all workers
await Promise.all(workers.map(worker => worker.terminate()));
console.log('main\t✅ All workers terminated. Exiting.');
process.exit(0);
});