make the globals const
This commit is contained in:
@@ -16,9 +16,8 @@ const apps = require('./apps.js'),
|
|||||||
safe = require('safetydance'),
|
safe = require('safetydance'),
|
||||||
_ = require('underscore');
|
_ = require('underscore');
|
||||||
|
|
||||||
// appId -> { containerId, schedulerConfig (manifest), cronjobs }
|
const gState = {}; // appId -> { containerId, schedulerConfig (manifest), cronjobs }
|
||||||
let gState = { };
|
const gSuspendedAppIds = new Set(); // suspended because some apptask is running
|
||||||
let gSuspendedAppIds = new Set(); // suspended because some apptask is running
|
|
||||||
|
|
||||||
// TODO: this should probably also stop existing jobs to completely prevent race but the code is not re-entrant
|
// TODO: this should probably also stop existing jobs to completely prevent race but the code is not re-entrant
|
||||||
function suspendJobs(appId) {
|
function suspendJobs(appId) {
|
||||||
@@ -120,10 +119,9 @@ async function sync() {
|
|||||||
debug(`sync: removing jobs of ${appId}`);
|
debug(`sync: removing jobs of ${appId}`);
|
||||||
const [error] = await safe(stopJobs(appId, gState[appId]));
|
const [error] = await safe(stopJobs(appId, gState[appId]));
|
||||||
if (error) debug(`sync: error stopping jobs of removed app ${appId}: ${error.message}`);
|
if (error) debug(`sync: error stopping jobs of removed app ${appId}: ${error.message}`);
|
||||||
|
delete gState[appId];
|
||||||
}
|
}
|
||||||
|
|
||||||
gState = _.omit(gState, removedAppIds);
|
|
||||||
|
|
||||||
for (const app of allApps) {
|
for (const app of allApps) {
|
||||||
const appState = gState[app.id] || null;
|
const appState = gState[app.id] || null;
|
||||||
const schedulerConfig = apps.getSchedulerConfig(app);
|
const schedulerConfig = apps.getSchedulerConfig(app);
|
||||||
|
|||||||
Reference in New Issue
Block a user