mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 18:38:09 +01:00
Detect and log if processes end unexpectedly.
This commit is contained in:
@@ -278,6 +278,26 @@ def getCoreBinArgs(coin_id: int, coin_settings, prepare=False, use_tor_proxy=Fal
|
|||||||
return extra_args
|
return extra_args
|
||||||
|
|
||||||
|
|
||||||
|
def mainLoop(daemons, update: bool = True):
|
||||||
|
while not swap_client.delay_event.wait(0.5):
|
||||||
|
if update:
|
||||||
|
swap_client.update()
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
for daemon in daemons:
|
||||||
|
if daemon.running is False:
|
||||||
|
continue
|
||||||
|
poll = daemon.handle.poll()
|
||||||
|
if poll is None:
|
||||||
|
pass # Process is running
|
||||||
|
else:
|
||||||
|
daemon.running = False
|
||||||
|
swap_client.log.error(
|
||||||
|
f"Process {daemon.handle.pid} for {daemon.name} terminated unexpectedly returning {poll}."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def runClient(
|
def runClient(
|
||||||
data_dir: str,
|
data_dir: str,
|
||||||
chain: str,
|
chain: str,
|
||||||
@@ -522,8 +542,7 @@ def runClient(
|
|||||||
logger.info(
|
logger.info(
|
||||||
f"Only running {start_only_coins}. Manually exit with Ctrl + c when ready."
|
f"Only running {start_only_coins}. Manually exit with Ctrl + c when ready."
|
||||||
)
|
)
|
||||||
while not swap_client.delay_event.wait(0.5):
|
mainLoop(daemons, update=False)
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
swap_client.start()
|
swap_client.start()
|
||||||
if "htmlhost" in settings:
|
if "htmlhost" in settings:
|
||||||
@@ -561,8 +580,7 @@ def runClient(
|
|||||||
swap_client.ws_server.run_forever(threaded=True)
|
swap_client.ws_server.run_forever(threaded=True)
|
||||||
|
|
||||||
logger.info("Exit with Ctrl + c.")
|
logger.info("Exit with Ctrl + c.")
|
||||||
while not swap_client.delay_event.wait(0.5):
|
mainLoop(daemons)
|
||||||
swap_client.update()
|
|
||||||
|
|
||||||
except Exception as e: # noqa: F841
|
except Exception as e: # noqa: F841
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|||||||
@@ -6,9 +6,10 @@
|
|||||||
|
|
||||||
|
|
||||||
class Daemon:
|
class Daemon:
|
||||||
__slots__ = ("handle", "files", "name")
|
__slots__ = ("handle", "files", "name", "running")
|
||||||
|
|
||||||
def __init__(self, handle, files, name):
|
def __init__(self, handle, files, name):
|
||||||
self.handle = handle
|
self.handle = handle
|
||||||
self.files = files
|
self.files = files
|
||||||
self.name = name
|
self.name = name
|
||||||
|
self.running = True
|
||||||
|
|||||||
Reference in New Issue
Block a user