Skip to content

Commit 33111e5

Browse files
authored
BUGFIX
check if dcs.log exists
1 parent f3823f0 commit 33111e5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

services/monitoring/service.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ async def heartbeat(self):
192192
return
193193
# only escalate, if the server was not stopped (maybe the process was manually shut down)
194194
if server.status != Status.STOPPED:
195-
now = datetime.now(timezone.utc)
196-
shutil.copy2(os.path.join(server.instance.home, 'Logs', 'dcs.log'),
197-
os.path.join(server.instance.home, 'Logs', f"dcs-{now.strftime('%Y%m%d-%H%M%S')}.log"))
195+
logfile = os.path.join(server.instance.home, 'Logs', 'dcs.log')
196+
if os.path.exists(logfile):
197+
now = datetime.now(timezone.utc)
198+
shutil.copy2(logfile, os.path.join(server.instance.home,
199+
'Logs', f"dcs-{now.strftime('%Y%m%d-%H%M%S')}.log"))
198200
title = f'Server "{server.name}" died!'
199201
message = 'Setting state to SHUTDOWN.'
200202
self.log.warning(title + ' ' + message)

0 commit comments

Comments
 (0)