Skip to content

Commit

Permalink
Output more logs for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Nov 7, 2014
1 parent ccf0ad6 commit 019d19e
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions bin/droonga-http-server
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,29 @@ application.droonga({
syncHostNames: true
});

server.listen(options.port, options.host);
try {
logger.info('Start to listen ' + options.host + ':' + options.port);
server.on('error', shutdown);
server.listen(options.port, options.host);
} catch(error) {
shutdown(error);
}

function shutdown() {
server.close();
if (options.pidFile && fs.existsSync(options.pidFile)) {
fs.unlinkSync(options.pidFile);
function shutdown(error) {
if (error) {
logger.error('Shutting down the server by an unexpected error.');
logger.error(error);
}

try {
server.close();
} catch(error) {
logger.error('Unexpected error on closing of the server.');
logger.error(error);
}

if (options.pidFile && fs.existsSync(options.pidFile))
fs.unlinkSync(options.pidFile);
}

process.on('SIGINT', function() {
Expand Down

0 comments on commit 019d19e

Please sign in to comment.