Skip to content

Commit

Permalink
Prevent debug mode check if running gunicorn server
Browse files Browse the repository at this point in the history
  • Loading branch information
jagraff committed May 2, 2024
1 parent 706388d commit f58f820
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hasher-matcher-actioner/src/OpenMediaMatch/app.py
Expand Up @@ -48,6 +48,10 @@ def _is_werkzeug_reloaded_process():
return os.environ.get("WERKZEUG_RUN_MAIN") == "true"


def _is_gunicorn():
return "gunicorn" in os.environ.get("SERVER_SOFTWARE", "")


def _setup_task_logging(app_logger: logging.Logger):
"""Clownily replace module loggers with our own"""
fetcher.logger = app_logger.getChild("Fetcher")
Expand Down Expand Up @@ -108,7 +112,7 @@ def create_app() -> flask.Flask:
with app.app_context():
# We only run apscheduler in the "outer" reloader process, else we'll
# have multiple executions of the the scheduler in debug mode
if _is_werkzeug_reloaded_process() and not running_migrations:
if (_is_werkzeug_reloaded_process() or _is_gunicorn()) and not running_migrations:
now = datetime.datetime.now()
scheduler = dev_apscheduler.get_apscheduler()
scheduler.init_app(app)
Expand Down

0 comments on commit f58f820

Please sign in to comment.