diff --git a/support/aphlict/server/aphlict_server.js b/support/aphlict/server/aphlict_server.js --- a/support/aphlict/server/aphlict_server.js +++ b/support/aphlict/server/aphlict_server.js @@ -43,6 +43,12 @@ var config = parse_command_line_arguments(process.argv); +function set_exit_code(code) { + process.on('exit', function() { + process.exit(code); + }); +} + process.on('uncaughtException', function(err) { var context = null; if (err.code == 'EACCES' && err.path == config.log) { @@ -61,6 +67,7 @@ message.push(err.stack); debug.log(message.join('\n\n')); + set_exit_code(1); }); try { @@ -98,7 +105,8 @@ // servers. if (config.test) { debug.log('Configuration test OK.'); - process.exit(0); + set_exit_code(0); + return; } var server;