Skip to content

Commit

Permalink
fix duplicate sigterm catch
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Krellenstein <[email protected]>
  • Loading branch information
Ouziel authored and adamkrellenstein committed Apr 17, 2024
1 parent cf7bfd0 commit 4a6af64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions counterparty-lib/counterpartylib/lib/api/api_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import logging
import multiprocessing
import signal
from multiprocessing import Process
from threading import Timer

Expand Down Expand Up @@ -93,6 +94,10 @@ def handle_route(**kwargs):


def run_api_server(args):
# default signal handlers
signal.signal(signal.SIGTERM, signal.SIG_DFL)
signal.signal(signal.SIGINT, signal.default_int_handler)

app = Flask(config.APP_NAME)
# Initialise log and config
server.initialise_log_and_config(argparse.Namespace(**args))
Expand Down
3 changes: 2 additions & 1 deletion counterparty-lib/counterpartylib/lib/api/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,15 @@ def init_api_access_log(flask_app):
flask_app.logger.removeHandler(flask.logging.default_handler)
flask_app.logger.setLevel(logging.DEBUG)
werkzeug_logger = logging.getLogger("werkzeug")
while werkzeug_logger.hasHandlers():
while len(werkzeug_logger.handlers) > 0:
werkzeug_logger.removeHandler(werkzeug_logger.handlers[0])

# Log to file, if configured...
if config.API_LOG:
handler = logging_handlers.RotatingFileHandler(
config.API_LOG, "a", config.API_MAX_LOG_SIZE, config.API_MAX_LOG_COUNT
)
handler.propagate = False
handler.setLevel(logging.DEBUG)
flask_app.logger.addHandler(handler)
werkzeug_logger.addHandler(handler)
Expand Down

0 comments on commit 4a6af64

Please sign in to comment.