diff --git a/src/apptask.js b/src/apptask.js index d4c26e917..f34100119 100644 --- a/src/apptask.js +++ b/src/apptask.js @@ -3,9 +3,6 @@ 'use strict'; exports = module.exports = { - initialize: initialize, - startTask: startTask, - run: run, // exported for testing @@ -30,7 +27,6 @@ var addons = require('./addons.js'), auditsource = require('./auditsource.js'), backups = require('./backups.js'), constants = require('./constants.js'), - database = require('./database.js'), DatabaseError = require('./databaseerror.js'), debug = require('debug')('box:apptask'), df = require('@sindresorhus/df'), @@ -62,15 +58,6 @@ var COLLECTD_CONFIG_EJS = fs.readFileSync(__dirname + '/collectd.config.ejs', { LOGROTATE_CONFIG_EJS = fs.readFileSync(__dirname + '/logrotate.ejs', { encoding: 'utf8' }), CONFIGURE_LOGROTATE_CMD = path.join(__dirname, 'scripts/configurelogrotate.sh'); -function initialize(callback) { - assert.strictEqual(typeof callback, 'function'); - - async.series([ - database.initialize, - settings.initCache - ], callback); -} - function debugApp(app) { assert.strictEqual(typeof app, 'object'); @@ -918,40 +905,6 @@ function handleRunCommand(app, progressCallback, callback) { return callback(null); } -function startTask(appId, callback) { - assert.strictEqual(typeof appId, 'string'); - assert.strictEqual(typeof callback, 'function'); - - // determine what to do - apps.get(appId, function (error, app) { - if (error) return callback(error); - - debugApp(app, 'startTask installationState: %s runState: %s', app.installationState, app.runState); - - switch (app.installationState) { - case appdb.ISTATE_PENDING_UNINSTALL: return uninstall(app, callback); - case appdb.ISTATE_PENDING_CONFIGURE: return configure(app, callback); - - case appdb.ISTATE_PENDING_UPDATE: return update(app, callback); - case appdb.ISTATE_PENDING_FORCE_UPDATE: return update(app, callback); - - case appdb.ISTATE_PENDING_INSTALL: return install(app, callback); - case appdb.ISTATE_PENDING_CLONE: return install(app, callback); - case appdb.ISTATE_PENDING_RESTORE: return install(app, callback); - - case appdb.ISTATE_PENDING_BACKUP: return backup(app, callback); - case appdb.ISTATE_INSTALLED: return handleRunCommand(app, callback); - - case appdb.ISTATE_ERROR: - debugApp(app, 'Internal error. apptask launched with error status.'); - return callback(null); - default: - debugApp(app, 'apptask launched with invalid command'); - return callback(new Error('Unknown command in apptask:' + app.installationState)); - } - }); -} - function run(appId, progressCallback, callback) { assert.strictEqual(typeof appId, 'string'); assert.strictEqual(typeof progressCallback, 'function'); @@ -980,29 +933,3 @@ function run(appId, progressCallback, callback) { } }); } - -if (require.main === module) { - assert.strictEqual(process.argv.length, 3, 'Pass the appid as argument'); - - // add a separator for the log file - debug('------------------------------------------------------------'); - debug('Apptask for %s', process.argv[2]); - - process.on('SIGTERM', function () { - debug('taskmanager sent SIGTERM since it got a new task for this app'); - process.exit(0); - }); - - initialize(function (error) { - if (error) throw error; - - startTask(process.argv[2], function (error) { - if (error) debug('Apptask completed with error', error); - - debug('Apptask completed for %s', process.argv[2]); - // https://nodejs.org/api/process.html are exit codes used by node. apps.js uses the value below - // to check apptask crashes - process.exit(error ? 50 : 0); - }); - }); -} diff --git a/src/test/apptask-test.js b/src/test/apptask-test.js index 1a5c698d1..273651180 100644 --- a/src/test/apptask-test.js +++ b/src/test/apptask-test.js @@ -128,10 +128,6 @@ describe('apptask', function () { ], done); }); - it('initializes succesfully', function (done) { - apptask.initialize(done); - }); - it('reserve port', function (done) { apptask._reserveHttpPort(APP, function (error) { expect(error).to.not.be.ok();