Преглед на файлове

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):
         """