pandora
Version:
A powerful and lightweight application manager for Node.js applications powered by TypeScript.
35 lines (32 loc) • 1.01 kB
JavaScript
;
const path = require('path');
const PANDORA_LIB_HOME = path.join(__dirname, '../dist');
const {consoleLogger} = require(path.join(PANDORA_LIB_HOME, 'universal/LoggerBroker'));
const {isDaemonRunning, send, barrierDaemon, getDaemonClient} = require(path.join(PANDORA_LIB_HOME, 'daemon/DaemonHandler'));
exports.command = 'exit';
exports.desc = 'Stop all applications and exit the pandora daemon process';
exports.handler = function () {
isDaemonRunning().then((isRunning) => {
if (!isRunning) {
consoleLogger.info('Daemon is not running yet');
process.exit(0);
return;
}
barrierDaemon().then(() => {
return getDaemonClient();
}).then((client) => {
client.once('error', () => {
process.exit(0);
});
send('exit', (err, data) => {
if (err) {
consoleLogger.error(err);
process.exit(1);
return;
}
consoleLogger.info(data);
process.exit(0);
});
});
});
};