more pid start rework
This commit is contained in:
parent
d4a38c3e14
commit
bff6988297
|
@ -28,6 +28,7 @@ class Application:
|
|||
self.setup_debug_hook()
|
||||
Window(args, unknownargs).main()
|
||||
|
||||
|
||||
def load_ipc(self, args, unknownargs):
|
||||
ipc_server = IPCServer()
|
||||
self.ipc_realization_check(ipc_server)
|
||||
|
|
|
@ -11,7 +11,8 @@ import inspect
|
|||
|
||||
|
||||
class StartCheckMixin:
|
||||
def is_dirty_start(self) -> bool: return self._dirty_start
|
||||
def is_dirty_start(self) -> bool:
|
||||
return self._dirty_start
|
||||
|
||||
def clear_pid(self):
|
||||
if not self.is_trace_debug():
|
||||
|
@ -23,28 +24,28 @@ class StartCheckMixin:
|
|||
self._print_pid(pid)
|
||||
return
|
||||
|
||||
if not os.path.exists(self._PID_FILE):
|
||||
self._write_new_pid()
|
||||
else:
|
||||
with open(self._PID_FILE, "r") as _pid:
|
||||
pid = _pid.readline().strip()
|
||||
if os.path.exists(self._PID_FILE):
|
||||
with open(self._PID_FILE, "r") as f:
|
||||
pid = f.readline().strip()
|
||||
if pid not in ("", None):
|
||||
self._check_alive_status(int(pid))
|
||||
else:
|
||||
if self.is_pid_alive( int(pid) ):
|
||||
print("PID file exists and PID is alive... Letting downstream errors (sans debug args) handle app closure propigation.")
|
||||
return
|
||||
|
||||
self._write_new_pid()
|
||||
|
||||
""" Check For the existence of a unix pid. """
|
||||
def _check_alive_status(self, pid):
|
||||
def is_pid_alive(self, pid):
|
||||
print(f"PID Found: {pid}")
|
||||
|
||||
try:
|
||||
os.kill(pid, 0)
|
||||
except OSError:
|
||||
print(f"{app_name} PID exists but is not up; starting dirty...")
|
||||
print(f"{app_name} PID file exists but PID is irrelevant; starting dirty...")
|
||||
self._dirty_start = True
|
||||
self._write_new_pid()
|
||||
return
|
||||
return False
|
||||
|
||||
print("PID is alive... Let downstream errors (sans debug args) handle app closure propigation.")
|
||||
return True
|
||||
|
||||
def _write_new_pid(self):
|
||||
pid = os.getpid()
|
||||
|
|
Loading…
Reference in New Issue