Release 16 (devel -> main) #39
1 changed files with 33 additions and 20 deletions
|
@ -14,6 +14,17 @@ from time import sleep
|
||||||
from yaml import safe_load
|
from yaml import safe_load
|
||||||
|
|
||||||
|
|
||||||
|
banner = """ ___ _ _
|
||||||
|
| \ _ _ (_) _ _ | |__ ___ ___
|
||||||
|
| |) || '_|| || ' \ | / /(_-< |___|
|
||||||
|
|___/ |_| |_||_||_||_\_\/__/
|
||||||
|
__ __ Version {version}
|
||||||
|
| \/ | __ _ _ _ __ _ __ _ ___ _ _
|
||||||
|
| |\/| |/ _` || ' \ / _` |/ _` |/ -_)| '_|
|
||||||
|
|_| |_|\__,_||_||_|\__,_|\__, |\___||_|
|
||||||
|
|___/
|
||||||
|
"""
|
||||||
|
|
||||||
base_directory = Path(__file__).parent.parent
|
base_directory = Path(__file__).parent.parent
|
||||||
data_directory = base_directory / "data"
|
data_directory = base_directory / "data"
|
||||||
logfile_directory = data_directory / "logs"
|
logfile_directory = data_directory / "logs"
|
||||||
|
@ -79,27 +90,29 @@ def cleanup_procs(processes):
|
||||||
|
|
||||||
|
|
||||||
def start_and_monitor(monitored_subprocesses: list):
|
def start_and_monitor(monitored_subprocesses: list):
|
||||||
|
# display banner
|
||||||
|
print(banner.format(version=os.environ["APP_VERSION"]))
|
||||||
# start processes
|
# start processes
|
||||||
for p in monitored_subprocesses:
|
for p in monitored_subprocesses:
|
||||||
p.try_start()
|
p.try_start()
|
||||||
register_exithandler(cleanup_procs, monitored_subprocesses)
|
register_exithandler(cleanup_procs, monitored_subprocesses)
|
||||||
# monitor processes
|
# monitor processes
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
sleep(1)
|
sleep(1)
|
||||||
for p in monitored_subprocesses:
|
for p in monitored_subprocesses:
|
||||||
returncode = p.s.poll()
|
returncode = p.s.poll()
|
||||||
if returncode is None:
|
if returncode is None:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
print(f"{p.name} stopped with exit code {returncode}.")
|
print(f"{p.name} stopped with exit code {returncode}.")
|
||||||
if p.try_start() is False:
|
if p.try_start() is False:
|
||||||
# stop everything if the process
|
# stop everything if the process
|
||||||
# has exceeded max. tries
|
# has exceeded max. tries
|
||||||
exit()
|
exit()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("Received KeyboardInterrupt, exiting...")
|
print("Received KeyboardInterrupt, exiting...")
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue