Files
cloudron-box/box.js

59 lines
1.6 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
'use strict';
// prefix all output with a timestamp
// debug() already prefixes and uses process.stderr NOT console.*
['log', 'info', 'warn', 'debug', 'error'].forEach(function (log) {
var orig = console[log];
console[log] = function () {
orig.apply(console, [new Date().toISOString()].concat(Array.prototype.slice.call(arguments)));
};
});
require('supererror')({ splatchError: true });
let async = require('async'),
2019-07-26 15:01:47 -07:00
constants = require('./src/constants.js'),
2018-08-13 21:10:53 +02:00
dockerProxy = require('./src/dockerproxy.js'),
2019-07-26 15:01:47 -07:00
ldap = require('./src/ldap.js'),
server = require('./src/server.js');
console.log();
console.log('==========================================');
console.log(` Cloudron ${constants.VERSION} `);
console.log('==========================================');
console.log();
async.series([
server.start,
ldap.start,
dockerProxy.start
], function (error) {
if (error) {
console.error('Error starting server', error);
process.exit(1);
}
console.log('Cloudron is up and running');
});
var NOOP_CALLBACK = function () { };
process.on('SIGINT', function () {
2018-11-08 14:35:22 +01:00
console.log('Received SIGINT. Shutting down.');
server.stop(NOOP_CALLBACK);
2015-09-14 10:59:05 -07:00
ldap.stop(NOOP_CALLBACK);
2018-08-13 21:10:53 +02:00
dockerProxy.stop(NOOP_CALLBACK);
setTimeout(process.exit.bind(process), 3000);
});
process.on('SIGTERM', function () {
2018-11-08 14:35:22 +01:00
console.log('Received SIGTERM. Shutting down.');
server.stop(NOOP_CALLBACK);
2015-09-14 10:59:05 -07:00
ldap.stop(NOOP_CALLBACK);
2018-08-13 21:10:53 +02:00
dockerProxy.stop(NOOP_CALLBACK);
setTimeout(process.exit.bind(process), 3000);
});