mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Handle SIGTERM
This commit is contained in:
parent
5a5cd65d4f
commit
344c2219ec
10
main.py
10
main.py
@ -4,6 +4,7 @@ import json
|
||||
import time
|
||||
import argparse
|
||||
import logging.config
|
||||
import signal
|
||||
|
||||
""" Our custom classes / pip packages """
|
||||
from app.classes.shared.console import console
|
||||
@ -128,6 +129,15 @@ if __name__ == '__main__':
|
||||
tasks_manager.start_main_kill_switch_watcher()
|
||||
|
||||
Crafty = MainPrompt(tasks_manager)
|
||||
|
||||
def sigterm_handler(signum, current_stack_frame):
|
||||
print() # for newline
|
||||
logger.info("Recieved SIGTERM, stopping Crafty")
|
||||
console.info("Recieved SIGTERM, stopping Crafty")
|
||||
Crafty.universal_exit()
|
||||
|
||||
signal.signal(signal.SIGTERM, sigterm_handler)
|
||||
|
||||
if not args.daemon:
|
||||
try:
|
||||
Crafty.cmdloop()
|
||||
|
Loading…
Reference in New Issue
Block a user