edit cronjob to 30 mins
This commit is contained in:
@@ -43,14 +43,14 @@ async function execWithTimeout(container, cmd, timeout = EXEC_TIMEOUT) {
|
||||
AttachStdout: true,
|
||||
AttachStderr: true
|
||||
});
|
||||
|
||||
|
||||
const stream = await exec.start();
|
||||
let output = '';
|
||||
|
||||
|
||||
const timeoutPromise = new Promise((_, reject) => {
|
||||
setTimeout(() => reject(new Error(`Command ${cmd.join(' ')} timed out after ${timeout}ms`)), timeout);
|
||||
});
|
||||
|
||||
|
||||
await Promise.race([
|
||||
new Promise((resolve, reject) => {
|
||||
stream.on('data', (chunk) => output += chunk.toString());
|
||||
@@ -59,7 +59,7 @@ async function execWithTimeout(container, cmd, timeout = EXEC_TIMEOUT) {
|
||||
}),
|
||||
timeoutPromise
|
||||
]);
|
||||
|
||||
|
||||
return output;
|
||||
} catch (err) {
|
||||
throw err;
|
||||
@@ -83,7 +83,7 @@ async function updateContainerConfig(container, name, userId, memoryLimit) {
|
||||
try {
|
||||
await execWithTimeout(container, ['test', '-f', '/var/tools/pm2/startServer.json']);
|
||||
console.log(` ✅ startServer.json exists`);
|
||||
|
||||
|
||||
// Remove existing startServer.json
|
||||
console.log(` 🗑️ Removing existing startServer.json in container ${name}...`);
|
||||
await execWithTimeout(container, ['rm', '-f', '/var/tools/pm2/startServer.json']);
|
||||
@@ -257,7 +257,7 @@ client.once('ready', () => {
|
||||
checkContainers();
|
||||
|
||||
// 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();
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user