copy the seastatus before first start after boot time

after a crash the previous seastatus is not read correctly
for debugging reasons we should check if the status file is
invalid
This commit is contained in:
zolliker 2023-11-14 11:40:56 +01:00
parent 785ca1b290
commit 7f2ba5766c

View File

@ -24,6 +24,7 @@ import sys
import time
import termios
import subprocess
import psutil
import os
import re
from os.path import join, exists
@ -112,8 +113,26 @@ class SeaManager(ServiceManager):
except Exception:
pass
os.system('cp %s ./' % sea_server_src)
if service == 'sea':
# debugging: copy status file in case of a reboot
seastatus = self.get_sea_status(ins)
if seastatus:
boot_time = time.strftime("%Y-%m-%dT%H-%M-%S", time.localtime(psutil.boot_time()))
dst = seastatus.replace('.tcl', '') + '.' + boot_time
if not exists(dst):
os.system(f'cp {seastatus} {dst}')
return start_dir, env
def get_sea_status_file(self, ins):
searoot = self.env[ins].get('SEA_ROOT', '')
seastatus = join(searoot, ins, 'status', 'seastatus.tcl')
if exists(seastatus):
return seastatus
seastatus = join(searoot, 'status', 'seastatus.tcl')
if exists(seastatus):
return seastatus
return None
def get_cfg(self, ins, service, addconfirmed=False):
"""return cfg info about running programs, if relevant
@ -124,11 +143,8 @@ class SeaManager(ServiceManager):
if 'sea' not in self.get_procs().get(ins, ()):
return ''
try:
searoot = self.env[ins].get('SEA_ROOT', '')
seastatus = join(searoot, ins, 'status', 'seastatus.tcl')
if not exists(seastatus):
seastatus = join(searoot, 'status', 'seastatus.tcl')
if not exists(seastatus):
seastatus = self.get_sea_status(ins)
if not seastatus:
return '?'
result = ['', '']
confirmed = ''