mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
attempt with rigctld watchdog
This commit is contained in:
parent
36d6f061b2
commit
e30d71a85e
|
@ -32,7 +32,6 @@ import structlog
|
||||||
import ujson as json
|
import ujson as json
|
||||||
import config
|
import config
|
||||||
|
|
||||||
|
|
||||||
# signal handler for closing application
|
# signal handler for closing application
|
||||||
def signal_handler(sig, frame):
|
def signal_handler(sig, frame):
|
||||||
"""
|
"""
|
||||||
|
@ -77,6 +76,44 @@ class DAEMON:
|
||||||
worker = threading.Thread(target=self.worker, name="WORKER", daemon=True)
|
worker = threading.Thread(target=self.worker, name="WORKER", daemon=True)
|
||||||
worker.start()
|
worker.start()
|
||||||
|
|
||||||
|
rigctld_watchdog_thread = threading.Thread(target=self.rigctld_watchdog, name="WORKER", daemon=True)
|
||||||
|
rigctld_watchdog_thread.start()
|
||||||
|
|
||||||
|
|
||||||
|
def rigctld_watchdog(self):
|
||||||
|
"""
|
||||||
|
Check for rigctld status
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
while True:
|
||||||
|
threading.Event().wait(0.3)
|
||||||
|
# only continue, if we have a process object initialized
|
||||||
|
if hasattr(Daemon.rigctldprocess, "returncode"):
|
||||||
|
|
||||||
|
if Daemon.rigctldprocess.returncode in [None, "None"] or not Daemon.rigctldstarted:
|
||||||
|
Daemon.rigctldstarted = True
|
||||||
|
outs, errs = Daemon.rigctldprocess.communicate(timeout=30)
|
||||||
|
print(f"outs: {outs}")
|
||||||
|
print(f"errs: {errs}")
|
||||||
|
#print(Daemon.rigctldprocess.stderr.read())
|
||||||
|
else:
|
||||||
|
self.log.warning("[DMN] [RIGCTLD] [Watchdog] returncode detected",process=Daemon.rigctldprocess)
|
||||||
|
Daemon.rigctldstarted = False
|
||||||
|
# triggering another kill
|
||||||
|
Daemon.rigctldprocess.kill()
|
||||||
|
# erase process object
|
||||||
|
Daemon.rigctldprocess = None
|
||||||
|
else:
|
||||||
|
Daemon.rigctldstarted = False
|
||||||
|
|
||||||
|
#try:
|
||||||
|
# outs, errs = proc.communicate(timeout=15)
|
||||||
|
#except TimeoutExpired:
|
||||||
|
# proc.kill()
|
||||||
|
# outs, errs = proc.communicate()
|
||||||
|
|
||||||
|
|
||||||
def update_audio_devices(self):
|
def update_audio_devices(self):
|
||||||
"""
|
"""
|
||||||
Update audio devices and set to static
|
Update audio devices and set to static
|
||||||
|
@ -374,7 +411,7 @@ class DAEMON:
|
||||||
self.log.info("[DMN] starting rigctld: ", param=command)
|
self.log.info("[DMN] starting rigctld: ", param=command)
|
||||||
|
|
||||||
if not isWin:
|
if not isWin:
|
||||||
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
|
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
else:
|
else:
|
||||||
#On windows, open rigctld in new window for easier troubleshooting
|
#On windows, open rigctld in new window for easier troubleshooting
|
||||||
proc = subprocess.Popen(command, creationflags=subprocess.CREATE_NEW_CONSOLE,close_fds=True)
|
proc = subprocess.Popen(command, creationflags=subprocess.CREATE_NEW_CONSOLE,close_fds=True)
|
||||||
|
|
|
@ -1144,6 +1144,9 @@ class ThreadedTCPRequestHandler(socketserver.StreamRequestHandler):
|
||||||
try:
|
try:
|
||||||
log.warning("[SCK] Stopping Modem")
|
log.warning("[SCK] Stopping Modem")
|
||||||
Daemon.modemstarted = False
|
Daemon.modemstarted = False
|
||||||
|
# we need to run this twice, otherwise process won't be stopped
|
||||||
|
Daemon.modemprocess.kill()
|
||||||
|
threading.Event().wait(0.3)
|
||||||
Daemon.modemprocess.kill()
|
Daemon.modemprocess.kill()
|
||||||
# unregister process from atexit to avoid process zombies
|
# unregister process from atexit to avoid process zombies
|
||||||
atexit.unregister(Daemon.modemprocess.kill)
|
atexit.unregister(Daemon.modemprocess.kill)
|
||||||
|
|
Loading…
Reference in a new issue