[Groonga-commit] droonga/droonga-http-server at 019d19e [master] Output more logs for debugging

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Nov 7 12:09:50 JST 2014


YUKI Hiroshi	2014-11-07 12:09:50 +0900 (Fri, 07 Nov 2014)

  New Revision: 019d19e2c90278dbf86dc84d4123cd984e841a27
  https://github.com/droonga/droonga-http-server/commit/019d19e2c90278dbf86dc84d4123cd984e841a27

  Message:
    Output more logs for debugging

  Modified files:
    bin/droonga-http-server

  Modified: bin/droonga-http-server (+21 -5)
===================================================================
--- bin/droonga-http-server    2014-11-05 17:25:53 +0900 (bce50d4)
+++ bin/droonga-http-server    2014-11-07 12:09:50 +0900 (4ae6f6e)
@@ -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() {
-------------- next part --------------
HTML����������������������������...
下載 



More information about the Groonga-commit mailing list
Back to archive index