sigint handler added
This commit is contained in:
@ -5,6 +5,8 @@ import argparse
|
|||||||
import json
|
import json
|
||||||
import threading
|
import threading
|
||||||
import queue
|
import queue
|
||||||
|
import signal
|
||||||
|
|
||||||
|
|
||||||
deathBell = threading.Event()
|
deathBell = threading.Event()
|
||||||
|
|
||||||
@ -14,6 +16,12 @@ def exceptHook(args):
|
|||||||
deathBell.set()
|
deathBell.set()
|
||||||
logger.error("rang the death bell")
|
logger.error("rang the death bell")
|
||||||
|
|
||||||
|
def terminateHook(sig, frame):
|
||||||
|
global deathBell
|
||||||
|
logger.error("SIGINT received")
|
||||||
|
deathBell.set()
|
||||||
|
logger.error("rang the death bell")
|
||||||
|
|
||||||
|
|
||||||
logger.info("opcua2mqtt bridge starting")
|
logger.info("opcua2mqtt bridge starting")
|
||||||
|
|
||||||
@ -44,6 +52,9 @@ for o in config['opcua']:
|
|||||||
threading.excepthook = exceptHook
|
threading.excepthook = exceptHook
|
||||||
logger.info("Threading excepthook set")
|
logger.info("Threading excepthook set")
|
||||||
|
|
||||||
|
signal.signal(signal.SIGINT, terminateHook)
|
||||||
|
logger.info("SIGINT handler set")
|
||||||
|
|
||||||
logger.info("opcua2mqtt bridge is running")
|
logger.info("opcua2mqtt bridge is running")
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user