Skip to content

Commit

Permalink
extended jarklin run with logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Barakudum committed Feb 22, 2024
1 parent 92771eb commit bf2da92
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/jarklin/_commands/run/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

def run():
import time
import logging
import multiprocessing
from ..web import run as web_run
from ..cache import run as cache_run
Expand All @@ -20,9 +21,17 @@ def run():
while web.is_alive() and cache.is_alive():
time.sleep(1)
except KeyboardInterrupt:
logging.info("Caught KeyboardInterrupt. Shutting down...")
if web.is_alive():
web.terminate()
if cache.is_alive():
cache.terminate()
web.join(timeout=10)
cache.join(timeout=10)
else:
if web.is_alive(): # web alive, cache crashed
web.terminate()
logging.critical("jarklin-cache crashed")
if cache.is_alive(): # cache alive, web crashed
cache.terminate()
logging.critical("jarklin-web crashed")

0 comments on commit bf2da92

Please sign in to comment.