瀏覽代碼

Update loggers.py

If the active log file (at least stdout-log for a supervised proccess) is removed, the log file will not be recreated. When loggers.py tries to do "os.rename(self.baseFilename, dfn)" in RotatingFileHandler.removeAndRename (called by RotatingFileHandler.doRollover) it will fail with OSError, no new file is opened, and the managed process will later be stuck in a write.

It's not uncommon with cleanup scripts in /tmp, and /tmp is the default location for the logs...
Magnus Lyckå 11 年之前
父節點
當前提交
16b46ac019
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      supervisor/loggers.py

+ 8 - 2
supervisor/loggers.py

@@ -190,10 +190,16 @@ class RotatingFileHandler(FileHandler):
             try:
                 os.remove(dfn)
             except OSError, why:
-                # catch race condition (already deleted)
+                # catch race condition (destination already deleted)
                 if why.args[0] != errno.ENOENT:
                     raise
-        os.rename(sfn, dfn)
+        try:
+            os.rename(sfn, dfn)
+        except OSError, why:
+            # catch exceptional condition (source deleted)
+            # E.g. cleanup script removes active log.
+            if why[0] != errno.ENOENT:
+                raise
 
     def doRollover(self):
         """