edit cronjob to 30 mins

This commit is contained in:
MCHost
2025-07-23 03:43:16 -04:00
parent 1dee538b99
commit dc52310e0a

View File

@@ -43,14 +43,14 @@ async function execWithTimeout(container, cmd, timeout = EXEC_TIMEOUT) {
AttachStdout: true, AttachStdout: true,
AttachStderr: true AttachStderr: true
}); });
const stream = await exec.start(); const stream = await exec.start();
let output = ''; let output = '';
const timeoutPromise = new Promise((_, reject) => { const timeoutPromise = new Promise((_, reject) => {
setTimeout(() => reject(new Error(`Command ${cmd.join(' ')} timed out after ${timeout}ms`)), timeout); setTimeout(() => reject(new Error(`Command ${cmd.join(' ')} timed out after ${timeout}ms`)), timeout);
}); });
await Promise.race([ await Promise.race([
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
stream.on('data', (chunk) => output += chunk.toString()); stream.on('data', (chunk) => output += chunk.toString());
@@ -59,7 +59,7 @@ async function execWithTimeout(container, cmd, timeout = EXEC_TIMEOUT) {
}), }),
timeoutPromise timeoutPromise
]); ]);
return output; return output;
} catch (err) { } catch (err) {
throw err; throw err;
@@ -83,7 +83,7 @@ async function updateContainerConfig(container, name, userId, memoryLimit) {
try { try {
await execWithTimeout(container, ['test', '-f', '/var/tools/pm2/startServer.json']); await execWithTimeout(container, ['test', '-f', '/var/tools/pm2/startServer.json']);
console.log(` ✅ startServer.json exists`); console.log(` ✅ startServer.json exists`);
// Remove existing startServer.json // Remove existing startServer.json
console.log(` 🗑️ Removing existing startServer.json in container ${name}...`); console.log(` 🗑️ Removing existing startServer.json in container ${name}...`);
await execWithTimeout(container, ['rm', '-f', '/var/tools/pm2/startServer.json']); await execWithTimeout(container, ['rm', '-f', '/var/tools/pm2/startServer.json']);
@@ -257,7 +257,7 @@ client.once('ready', () => {
checkContainers(); checkContainers();
// Cron job every 5 minutes // Cron job every 5 minutes
const job = new CronJob('*/5 * * * *', checkContainers, null, true, 'UTC'); const job = new CronJob('*/30 * * * *', checkContainers, null, true, 'UTC');
job.start(); job.start();
}); });