Update Banyak
This commit is contained in:
+60
-12
@@ -1,33 +1,81 @@
|
||||
// const { exec } = require('child_process');
|
||||
// const path = require('path');
|
||||
|
||||
// // Jalur ke executable PHP
|
||||
// const phpExecutablePath = '/www/server/php/74/bin/php'; // Jalur yang sesuai dengan sistem Anda
|
||||
|
||||
// // 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'),
|
||||
// ];
|
||||
|
||||
// // Fungsi untuk menjalankan file PHP
|
||||
// function runPhpScripts() {
|
||||
// phpScriptPaths.forEach((phpScriptPath) => {
|
||||
// console.log(`Running command: ${phpExecutablePath} ${phpScriptPath}`);
|
||||
// exec(`${phpExecutablePath} ${phpScriptPath}`, (error, stdout, stderr) => {
|
||||
// if (error) {
|
||||
// console.error(`Error executing PHP script ${phpScriptPath}: ${error.message}`);
|
||||
// return;
|
||||
// }
|
||||
// if (stderr) {
|
||||
// console.error(`PHP script ${phpScriptPath} stderr: ${stderr}`);
|
||||
// return;
|
||||
// }
|
||||
// console.log(`PHP script ${phpScriptPath} output: ${stdout}`);
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
|
||||
// // Jalankan PHP scripts segera dan kemudian setiap 5 detik
|
||||
// runPhpScripts();
|
||||
// setInterval(runPhpScripts, 5000);
|
||||
|
||||
const { exec } = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
// Jalur ke executable PHP
|
||||
const phpExecutablePath = '/www/server/php/74/bin/php'; // Jalur yang sesuai dengan sistem Anda
|
||||
const phpExecutablePath = '/www/server/php/74/bin/php';
|
||||
|
||||
// Daftar jalur ke file PHP
|
||||
const phpScriptPaths = [
|
||||
path.join(__dirname, 'load_pesan.php'),
|
||||
path.join(__dirname, 'create_link_flip.php')
|
||||
path.join(__dirname, 'load_tagihan_flip.php'),
|
||||
path.join(__dirname, 'create_link_flip.php'),
|
||||
path.join(__dirname, 'load_tagihan_paydisini.php'),
|
||||
];
|
||||
|
||||
// Fungsi untuk menjalankan file PHP
|
||||
function runPhpScripts() {
|
||||
phpScriptPaths.forEach((phpScriptPath) => {
|
||||
// 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}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
} else if (stderr) {
|
||||
console.error(`PHP script ${phpScriptPath} stderr: ${stderr}`);
|
||||
return;
|
||||
} else {
|
||||
console.log(`PHP script ${phpScriptPath} output: ${stdout}`);
|
||||
}
|
||||
console.log(`PHP script ${phpScriptPath} output: ${stdout}`);
|
||||
resolve(); // tetap resolve biar lanjut meskipun error
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Jalankan PHP scripts segera dan kemudian setiap 5 detik
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Jalankan pertama kali
|
||||
runPhpScripts();
|
||||
setInterval(runPhpScripts, 5000);
|
||||
Reference in New Issue
Block a user