2015-07-20 00:09:47 -07:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
2018-11-16 12:21:32 +01:00
|
|
|
// 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)));
|
|
|
|
|
};
|
|
|
|
|
});
|
2015-07-20 00:09:47 -07:00
|
|
|
|
2018-11-16 12:21:32 +01:00
|
|
|
require('supererror')({ splatchError: true });
|
2015-09-21 09:05:14 -07:00
|
|
|
|
2018-10-22 11:39:42 -07:00
|
|
|
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'),
|
2017-03-19 00:36:05 -07:00
|
|
|
server = require('./src/server.js');
|
2015-07-20 00:09:47 -07:00
|
|
|
|
|
|
|
|
console.log();
|
|
|
|
|
console.log('==========================================');
|
2019-07-26 10:49:29 -07:00
|
|
|
console.log(` Cloudron ${constants.VERSION} `);
|
2015-07-20 00:09:47 -07:00
|
|
|
console.log('==========================================');
|
|
|
|
|
console.log();
|
|
|
|
|
|
2015-09-14 10:52:11 -07:00
|
|
|
async.series([
|
|
|
|
|
server.start,
|
|
|
|
|
ldap.start,
|
2018-10-22 11:39:42 -07:00
|
|
|
dockerProxy.start
|
2015-09-14 10:52:11 -07:00
|
|
|
], function (error) {
|
|
|
|
|
if (error) {
|
|
|
|
|
console.error('Error starting server', error);
|
2015-07-20 00:09:47 -07:00
|
|
|
process.exit(1);
|
|
|
|
|
}
|
2016-10-24 14:52:30 -07:00
|
|
|
console.log('Cloudron is up and running');
|
2015-07-20 00:09:47 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var NOOP_CALLBACK = function () { };
|
|
|
|
|
|
2015-09-09 16:57:41 -07:00
|
|
|
process.on('SIGINT', function () {
|
2018-11-08 14:35:22 +01:00
|
|
|
console.log('Received SIGINT. Shutting down.');
|
|
|
|
|
|
2015-09-09 16:57:41 -07:00
|
|
|
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);
|
2015-09-09 16:57:41 -07:00
|
|
|
setTimeout(process.exit.bind(process), 3000);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
process.on('SIGTERM', function () {
|
2018-11-08 14:35:22 +01:00
|
|
|
console.log('Received SIGTERM. Shutting down.');
|
|
|
|
|
|
2015-09-09 16:57:41 -07:00
|
|
|
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);
|
2015-09-09 16:57:41 -07:00
|
|
|
setTimeout(process.exit.bind(process), 3000);
|
|
|
|
|
});
|