maniajs
Version:
ManiaPlanet (Dedicated) Server Controller.
54 lines (38 loc) • 1.73 kB
JavaScript
/**
* Used to boot the controller
*
* Execute like this: 'npm start [arguments]'
*/
;
var _commander = require('commander');
var _package = require('./../package.json');
var packageInfo = _interopRequireWildcard(_package);
var _configuration = require('./util/configuration');
var configuration = _interopRequireWildcard(_configuration);
var _boot = require('./boot');
var _boot2 = _interopRequireDefault(_boot);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
/** Init with CMD options */
// Configuration
var program = new _commander.Command().version(packageInfo.version).option('-v, --verbose', 'More information in logs').option('-c, --config [location]', 'Run with config file location given').parse(process.argv);
/** Load config */
// Import package.json information. This is used for getting version info.
try {
var configPath = null;
if (typeof program.config === 'string') {
configPath = program.config;
} else if (process.env.hasOwnProperty('MJS_CONFIG_PATH')) {
configPath = process.env.MJS_CONFIG_PATH;
} else {
configPath = null;
}
configuration.load(configPath);
configuration.validate();
} catch (err) {
console.error("Error reading configuration (config.yaml), you could try to provide custom configuration path with -c/--config [path]:");
console.error(err);
process.exit(1);
}
/** Boot Controller */
(0, _boot2.default)();