소스 검색

HUE-241. Make supervisor launch errors more visible

All errors on the python side goes into error.log. This includes errors from
supervisor. Admin can track errors from just one file.

Errors from java (log4j) are still going into the daemons' respective logs.
bc Wong 15 년 전
부모
커밋
0362dd04bf
2개의 변경된 파일15개의 추가작업 그리고 9개의 파일을 삭제
  1. 10 4
      desktop/conf/log.conf
  2. 5 5
      desktop/core/src/desktop/supervisor.py

+ 10 - 4
desktop/conf/log.conf

@@ -11,10 +11,10 @@
 ########################################
 
 [logger_root]
-handlers=logfile
+handlers=logfile,errorlog
 
 [logger_access]
-handlers=access
+handlers=accesslog
 qualname=access
 
 [handler_stderr]
@@ -23,13 +23,19 @@ formatter=default
 level=DEBUG
 args=(sys.stderr,)
 
-[handler_access]
+[handler_accesslog]
 class=handlers.RotatingFileHandler
 level=INFO
 propagate=True
 formatter=access
 args=('%LOG_DIR%/access.log', 'a', 1000000, 3)
 
+[handler_errorlog]
+class=handlers.RotatingFileHandler
+level=ERROR
+formatter=default
+args=('%LOG_DIR%/error.log', 'a', 1000000, 3)
+
 [handler_logfile]
 class=handlers.RotatingFileHandler
 # Choices are DEBUG, INFO, WARNING, ERROR, CRITICAL
@@ -54,7 +60,7 @@ datefmt=%d/%b/%Y %H:%M:%S +0000
 keys=root,access
 
 [handlers]
-keys=stderr,logfile,access
+keys=stderr,logfile,accesslog,errorlog
 
 [formatters]
 keys=default,access

+ 5 - 5
desktop/core/src/desktop/supervisor.py

@@ -147,7 +147,8 @@ class Supervisor(threading.Thread):
       et = time.time()
 
       if SHOULD_STOP:
-        raise Exception("Stopping %s because supervisor dying" % proc_str)
+        LOG.info("Stopping %s because supervisor exiting" % proc_str)
+        break
       restart_timestamps.append(et)
       restart_timestamps = [t for t in restart_timestamps if t > et - TIME_WINDOW]
       if len(restart_timestamps) > MAX_RESTARTS_IN_WINDOW:
@@ -234,7 +235,7 @@ def drop_privileges():
   """
   we_are_root = os.getuid() == 0
   if not we_are_root:
-    print >>sys.stderr, "[INFO] Not running as root, skipping privilege drop"
+    print >>sys.stdout, "[INFO] Not running as root, skipping privilege drop"
     return
 
   try:
@@ -335,8 +336,7 @@ def main():
     wait_loop(sups, options)
   except Exception, ex:
     LOG.exception("Exception in supervisor main loop")
-    shutdown(sups)
-    return 1
+    shutdown(sups)      # shutdown() exits the process
 
   return 0
 
@@ -350,7 +350,7 @@ def wait_loop(sups, options):
         if sup.state == Supervisor.FINISHED:
           sups.remove(sup)
         else:
-          shutdown(sups)
+          shutdown(sups)        # shutdown() exits the process
 
 
 if __name__ == "__main__":