handle SIGTERM
This commit is contained in:
parent
0ed69ef2f7
commit
185fdb67cb
@ -1,8 +1,3 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
from http.server import HTTPServer
|
from http.server import HTTPServer
|
||||||
from owrx.http import RequestHandler
|
from owrx.http import RequestHandler
|
||||||
from owrx.config import Config
|
from owrx.config import Config
|
||||||
@ -14,12 +9,26 @@ from owrx.websocket import WebSocketConnection
|
|||||||
from owrx.reporting import ReportingEngine
|
from owrx.reporting import ReportingEngine
|
||||||
from owrx.version import openwebrx_version
|
from owrx.version import openwebrx_version
|
||||||
from owrx.audio import DecoderQueue
|
from owrx.audio import DecoderQueue
|
||||||
|
import signal
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ThreadedHttpServer(ThreadingMixIn, HTTPServer):
|
class ThreadedHttpServer(ThreadingMixIn, HTTPServer):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SignalException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def handleSignal(sig, frame):
|
||||||
|
raise SignalException("Received Signal {sig}".format(sig=sig))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print(
|
print(
|
||||||
"""
|
"""
|
||||||
@ -36,6 +45,9 @@ Support and info: https://groups.io/g/openwebrx
|
|||||||
|
|
||||||
logger.info("OpenWebRX version {0} starting up...".format(openwebrx_version))
|
logger.info("OpenWebRX version {0} starting up...".format(openwebrx_version))
|
||||||
|
|
||||||
|
for sig in [signal.SIGINT, signal.SIGTERM]:
|
||||||
|
signal.signal(sig, handleSignal)
|
||||||
|
|
||||||
pm = Config.get()
|
pm = Config.get()
|
||||||
|
|
||||||
configErrors = Config.validateConfig()
|
configErrors = Config.validateConfig()
|
||||||
@ -63,7 +75,7 @@ Support and info: https://groups.io/g/openwebrx
|
|||||||
try:
|
try:
|
||||||
server = ThreadedHttpServer(("0.0.0.0", pm["web_port"]), RequestHandler)
|
server = ThreadedHttpServer(("0.0.0.0", pm["web_port"]), RequestHandler)
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
except KeyboardInterrupt:
|
except SignalException:
|
||||||
WebSocketConnection.closeAll()
|
WebSocketConnection.closeAll()
|
||||||
Services.stop()
|
Services.stop()
|
||||||
ReportingEngine.stopAll()
|
ReportingEngine.stopAll()
|
||||||
|
Loading…
Reference in New Issue
Block a user