scheduler: add debug if scheduler is running too long

This commit is contained in:
Girish Ramakrishnan
2024-02-08 10:53:59 +01:00
parent 0b201cee71
commit c978e3b7ea

View File

@@ -45,9 +45,10 @@ async function runTask(appId, taskName) {
if (app.installationState !== apps.ISTATE_INSTALLED || app.runState !== apps.RSTATE_RUNNING || app.health !== apps.HEALTH_HEALTHY) return;
const [error, data] = await safe(docker.inspect(containerName));
if (!error && data && data.State.Running === true) {
if (!error && data?.State?.Running === true) {
const jobStartTime = new Date(data.State.StartedAt); // iso 8601
if (new Date() - jobStartTime < JOB_MAX_TIME) return;
if ((new Date() - jobStartTime) < JOB_MAX_TIME) return;
debug(`runTask: ${containerName} is running too long, restarting`);
}
await docker.restartContainer(containerName);