const { exec } = require('child_process'); const path = require('path'); // Jalur ke executable PHP const phpExecutablePath = '/www/server/php/74/bin/php'; // Daftar jalur ke file PHP const phpScriptPaths = [ path.join(__dirname, 'load_pesan.php'), path.join(__dirname, 'load_tagihan_flip.php'), path.join(__dirname, 'create_link_flip.php'), path.join(__dirname, 'load_tagihan_paydisini.php'), ]; // --- File tambahan setiap 1 detik --- const loadWAOfficialPath = path.join(__dirname, 'load_pesan_official.php'); // Fungsi untuk menjalankan 1 file PHP (Promise) function runPhpScript(phpScriptPath) { return new Promise((resolve) => { console.log(`Running command: ${phpExecutablePath} ${phpScriptPath}`); exec(`${phpExecutablePath} ${phpScriptPath}`, (error, stdout, stderr) => { if (error) { console.error(`Error executing PHP script ${phpScriptPath}: ${error.message}`); } else if (stderr) { console.error(`PHP script ${phpScriptPath} stderr: ${stderr}`); } else { console.log(`PHP script ${phpScriptPath} output: ${stdout}`); } resolve(); // tetap resolve biar lanjut meskipun error }); }); } // Fungsi utama async function runPhpScripts() { // Jalankan semua script secara paralel await Promise.all(phpScriptPaths.map(runPhpScript)); // Random delay 5–15 detik const nextDelay = Math.floor(Math.random() * (10000 - 5000 + 1)) + 5000; console.log(`Next run in ${nextDelay / 1000} seconds\n`); // Jalankan lagi setelah delay setTimeout(runPhpScripts, nextDelay); } // Fungsi loop cepat (1 detik) function runLoadWAOfficial() { runPhpScript(loadWAOfficialPath).then(() => { setTimeout(runLoadWAOfficial, 1000); }); } // Jalankan pertama kali runPhpScripts(); runLoadWAOfficial();