Skip to content

Commit

Permalink
18284 Add pre-fork server hook to gunicorn config
Browse files Browse the repository at this point in the history
  • Loading branch information
argush3 committed Oct 30, 2023
1 parent 6beb1b1 commit ccf538f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions legal-api/gunicorn_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
"""

import os
import gunicorn_server

workers = int(os.environ.get('GUNICORN_PROCESSES', '1')) # pylint: disable=invalid-name
threads = int(os.environ.get('GUNICORN_THREADS', '1')) # pylint: disable=invalid-name

forwarded_allow_ips = '*' # pylint: disable=invalid-name
secure_scheme_headers = {'X-Forwarded-Proto': 'https'} # pylint: disable=invalid-name

# Server Hooks
pre_fork = gunicorn_server.pre_fork
12 changes: 12 additions & 0 deletions legal-api/gunicorn_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

import time


def pre_fork(server, worker):
# Delay loading of each worker by 5 seconds
# This is done to work around an issue where the Traction API is returning an invalid token. The issue happens
# when successive token retrieval calls are made with less than 2-3 seconds between the calls.
time.sleep(5)


pre_fork = pre_fork

0 comments on commit ccf538f

Please sign in to comment.