From 85aba589b860712b582bc14c48797012b6aa1b18 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Tue, 7 Feb 2017 20:25:30 -0800 Subject: [PATCH] Add hack to send heartbeat only after a minute of server running --- src/cron.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cron.js b/src/cron.js index 5f504c493..c48d027ed 100644 --- a/src/cron.js +++ b/src/cron.js @@ -52,9 +52,15 @@ function initialize(callback) { gHeartbeatJob = new CronJob({ cronTime: '00 */1 * * * *', // every minute onTick: cloudron.sendHeartbeat, - start: true + start: false }); - cloudron.sendHeartbeat(); // latest unpublished version of CronJob has runOnInit + // hack: send the first heartbeat only after we are running for 60 seconds + // required as we end up sending a heartbeat and then cloudron-setup reboots the server + setTimeout(function () { + if (!gHeartbeatJob) return; // already uninitalized + gHeartbeatJob.start(); + cloudron.sendHeartbeat(); + }, 1000 * 60); var randomHourMinute = Math.floor(60*Math.random()); gAliveJob = new CronJob({