ggs-cron/plugins/heartbeat.js

37 lines
834 B
JavaScript
Raw Normal View History

2025-08-06 16:01:57 +07:00
// continue;
const heartbeatApiInfo = {
version: 1,
changelogs: [
"17/4/25, create endpoint map @Pakin"
],
};
let heartbeatTask = CronJobs.doEveryMinute(() => {
Log.debug("[hb] test heartbeat");
Log.debug(`[hb] current running tasks: ${JSON.stringify(CronJobs.getAllRunning.size)}`);
client.publish("log", {
msg: "heartbeat",
status: 200
});
2025-08-06 16:01:57 +07:00
}, 'heartbeat');
heartbeatTask.on('stop-heartbeat', () => heartbeatTask.stop());
cronTasks[0] = heartbeatTask;
endpointMap = {
'': function(req, res, next){
res.locals.title = "heartbeat";
res.locals.version = heartbeatApiInfo.version;
res.locals.task_num = CronJobs.getAllRunning.size;
res.render("heartbeat");
},
2025-08-11 17:38:45 +07:00
'info': function(req, res, next){
res.json(heartbeatApiInfo);
}
2025-08-06 16:01:57 +07:00
};