Log: tolerate missing rotated log files on startup
Recursive _rotate() may have already moved or unlinked the source path by the time we try to rename it (also tolerates concurrent logrotate runs from /etc/cron.reboot). Catch FileNotFoundError instead of crashing bbctrl on startup.
This commit is contained in:
@@ -182,4 +182,11 @@ class Log(object):
|
|||||||
if n == 16: os.unlink(fullpath)
|
if n == 16: os.unlink(fullpath)
|
||||||
else: self._rotate(path, nextN)
|
else: self._rotate(path, nextN)
|
||||||
|
|
||||||
os.rename(fullpath, '%s.%d' % (path, nextN))
|
# The recursive call may have unlinked or rotated this
|
||||||
|
# path; tolerate a missing source rather than crashing
|
||||||
|
# bbctrl on startup. This also tolerates concurrent
|
||||||
|
# logrotate runs from /etc/cron.reboot.
|
||||||
|
try:
|
||||||
|
os.rename(fullpath, '%s.%d' % (path, nextN))
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user