listen on timezone key only when configured

This commit is contained in:
Girish Ramakrishnan
2015-11-03 16:11:24 -08:00
parent b1dbb3570b
commit 9d9509525c
2 changed files with 5 additions and 2 deletions

View File

@@ -38,8 +38,6 @@ var NOOP_CALLBACK = function (error) { if (error) console.error(error); };
function initialize(callback) {
assert.strictEqual(typeof callback, 'function');
settings.events.on(settings.TIME_ZONE_KEY, recreateJobs);
gHeartbeatJob = new CronJob({
cronTime: '00 */1 * * * *', // every minute
onTick: cloudron.sendHeartbeat,
@@ -113,6 +111,9 @@ function recreateJobs(unusedTimeZone, callback) {
settings.events.on(settings.AUTOUPDATE_PATTERN_KEY, autoupdatePatternChanged);
autoupdatePatternChanged(allSettings[settings.AUTOUPDATE_PATTERN_KEY]);
settings.events.removeListener(settings.TIME_ZONE_KEY, recreateJobs);
settings.events.on(settings.TIME_ZONE_KEY, recreateJobs);
if (callback) callback();
});
}