Files
manjapro_v6/load/autoload.js
T
2025-10-07 21:01:15 +07:00

59 lines
1.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 515 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();