From 7f2ba5766ce63662b295eb5ccf27da9575320c02 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Tue, 14 Nov 2023 11:40:56 +0100 Subject: [PATCH] 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 --- seaman.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/seaman.py b/seaman.py index e720825..d83ec1d 100644 --- a/seaman.py +++ b/seaman.py @@ -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,12 +143,9 @@ 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): - return '?' + seastatus = self.get_sea_status(ins) + if not seastatus: + return '?' result = ['', ''] confirmed = '' with open(seastatus, 'r', encoding='utf-8') as f: