Переглянути джерело

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