const yargs = require('yargs'); var fs = require('fs'); /* Define configuration parameter */ yargs.alias('c', 'config').describe('c', 'olympus.json config location').string('rp'); args = yargs.argv; console.log('\x1b[36m%s\x1b[0m', "*********************************************************************"); console.log('\x1b[36m%s\x1b[0m', "* _____ _____ _____ ____ _ *"); console.log('\x1b[36m%s\x1b[0m', "* | __ \\ / ____|/ ____| / __ \\| | *"); console.log('\x1b[36m%s\x1b[0m', "* | | | | | | (___ | | | | |_ _ _ __ ___ _ __ _ _ ___ *"); console.log('\x1b[36m%s\x1b[0m', "* | | | | | \\___ \\ | | | | | | | | '_ ` _ \\| '_ \\| | | / __| *"); console.log('\x1b[36m%s\x1b[0m', "* | |__| | |____ ____) | | |__| | | |_| | | | | | | |_) | |_| \\__ \\ *"); console.log('\x1b[36m%s\x1b[0m', "* |_____/ \\_____|_____/ \\____/|_|\\__, |_| |_| |_| .__/ \\__,_|___/ *"); console.log('\x1b[36m%s\x1b[0m', "* __/ | | | *"); console.log('\x1b[36m%s\x1b[0m', "* |___/ |_| *"); console.log('\x1b[36m%s\x1b[0m', "*********************************************************************"); console.log('\x1b[36m%s\x1b[0m', ""); console.log("Please wait while DCS Olympus DEMO Backend Server starts up..."); console.log(`Config location: ${args["config"]}`) var fs = require('fs'); let rawdata = fs.readFileSync(args["config"]); let config = JSON.parse(rawdata); /** * Module dependencies. */ var app = require('../demo')(args["config"]); var debug = require('debug')('client:server'); var http = require('http'); /** * Get port from environment and store in Express. */ var configPort = null; if (config["backend"] != undefined && config["backend"]["port"] != undefined) { configPort = config["backend"]["port"]; } var port = normalizePort(configPort || '3001'); app.set('port', port); console.log("Express server listening on port: " + port) /** * Create HTTP server. */ var server = http.createServer(app); /** * Listen on provided port, on all network interfaces. */ server.listen(port); server.on('error', onError); server.on('listening', onListening); /** * Normalize a port into a number, string, or false. */ function normalizePort(val) { var port = parseInt(val, 10); if (isNaN(port)) { // named pipe return val; } if (port >= 0) { // port number return port; } return false; } /** * Event listener for HTTP server "error" event. */ function onError(error) { if (error.syscall !== 'listen') { throw error; } var bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port; // handle specific listen errors with friendly messages switch (error.code) { case 'EACCES': console.error(bind + ' requires elevated privileges'); process.exit(1); break; case 'EADDRINUSE': console.error(bind + ' is already in use'); process.exit(1); break; default: throw error; } } /** * Event listener for HTTP server "listening" event. */ function onListening() { var addr = server.address(); var bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port; debug('Listening on ' + bind); } console.log("DCS Olympus DEMO Backend Server {{OLYMPUS_VERSION_NUMBER}}.{{OLYMPUS_COMMIT_HASH}} started correctly!") console.log("Waiting for connections...") process.title = `DCS Olympus DEMO Backend Server {{OLYMPUS_VERSION_NUMBER}} (${port})`;