Changeset View
Changeset View
Standalone View
Standalone View
support/aphlict/server/aphlict_server.js
| Show All 37 Lines | |||||
| } | } | ||||
| var debug = new JX.AphlictLog() | var debug = new JX.AphlictLog() | ||||
| .addConsole(console); | .addConsole(console); | ||||
| var config = parse_command_line_arguments(process.argv); | var config = parse_command_line_arguments(process.argv); | ||||
| process.on('uncaughtException', function(err) { | process.on('uncaughtException', function(err) { | ||||
| debug.log('\n<<< UNCAUGHT EXCEPTION! >>>\n' + err.stack); | var context = null; | ||||
| if ((err.code == 'EACCES') && | |||||
| (err.path == config.log)) { | |||||
| context = util.format( | |||||
| 'Unable to open logfile ("%s"). Check that permissions are set ' + | |||||
| 'correctly.', | |||||
| err.path); | |||||
| } | |||||
| var message = [ | |||||
| '\n<<< UNCAUGHT EXCEPTION! >>>', | |||||
| ]; | |||||
| if (context) { | |||||
| message.push(context); | |||||
| } | |||||
| message.push(err.stack); | |||||
| debug.log(message.join('\n\n')); | |||||
| process.exit(1); | process.exit(1); | ||||
| }); | }); | ||||
| var WebSocket; | var WebSocket; | ||||
| try { | try { | ||||
| WebSocket = require('ws'); | WebSocket = require('ws'); | ||||
| } catch (ex) { | } catch (ex) { | ||||
| throw new Error( | throw new Error( | ||||
| Show All 9 Lines | |||||
| // Load the SSL certificates (if any were provided) now, so that runs with | // Load the SSL certificates (if any were provided) now, so that runs with | ||||
| // `--test` will see any errors. | // `--test` will see any errors. | ||||
| if (ssl_config.enabled) { | if (ssl_config.enabled) { | ||||
| ssl_config.key = fs.readFileSync(config['ssl-key']); | ssl_config.key = fs.readFileSync(config['ssl-key']); | ||||
| ssl_config.cert = fs.readFileSync(config['ssl-cert']); | ssl_config.cert = fs.readFileSync(config['ssl-cert']); | ||||
| } | } | ||||
| // Add the logfile so we'll fail if we can't write to it. | // Add the logfile so we'll fail if we can't write to it. | ||||
| if (config.logfile) { | if (config.log) { | ||||
| debug.addLogfile(config.logfile); | debug.addLogfile(config.log); | ||||
| } | } | ||||
| // If we're just doing a configuration test, exit here before starting any | // If we're just doing a configuration test, exit here before starting any | ||||
| // servers. | // servers. | ||||
| if (config.test) { | if (config.test) { | ||||
| debug.log('Configuration test OK.'); | debug.log('Configuration test OK.'); | ||||
| process.exit(0); | process.exit(0); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 164 Lines • Show Last 20 Lines | |||||