merge appdb.js into apps.js

This commit is contained in:
Girish Ramakrishnan
2021-08-20 09:19:44 -07:00
parent b6f2d6d620
commit 77f5cb183b
39 changed files with 1599 additions and 2495 deletions

View File

@@ -14,6 +14,7 @@ const apps = require('./apps.js'),
CronJob = require('cron').CronJob,
debug = require('debug')('box:scheduler'),
docker = require('./docker.js'),
util = require('util'),
_ = require('underscore');
// appId -> { containerId, schedulerConfig (manifest), cronjobs }
@@ -41,8 +42,9 @@ function runTask(appId, taskName, callback) {
if (gSuspendedAppIds.has(appId)) return callback();
apps.get(appId, function (error, app) {
util.callbackify(apps.get)(appId, function (error, app) {
if (error) return callback(error);
if (!app) return callback(new BoxError(BoxError.NOT_FOUND, 'App not found'));
if (app.installationState !== apps.ISTATE_INSTALLED || app.runState !== apps.RSTATE_RUNNING || app.health !== apps.HEALTH_HEALTHY) return callback();
@@ -121,7 +123,7 @@ function stopJobs(appId, appState, callback) {
function sync() {
if (constants.TEST) return;
apps.getAll(function (error, allApps) {
util.callbackify(apps.list)(function (error, allApps) {
if (error) return debug(`sync: error getting app list. ${error.message}`);
var allAppIds = allApps.map(function (app) { return app.id; });