fix minor startup error

This commit is contained in:
Kenneth Kehl
2025-02-03 10:40:55 -08:00
parent 0226c072f4
commit 3d6f112324
2 changed files with 14 additions and 18 deletions

View File

@@ -52,7 +52,8 @@ def cleanup_unfinished_jobs():
# The query already checks that the processing_finished time is null, so here we are saying
# if it started more than 4 hours ago, that's too long
try:
acceptable_finish_time = job.processing_started + timedelta(minutes=5)
if job.processing_started is not None:
acceptable_finish_time = job.processing_started + timedelta(minutes=5)
except TypeError:
current_app.logger.exception(
f"Job ID {job.id} processing_started is {job.processing_started}.",

View File

@@ -16,6 +16,18 @@ gunicorn.SERVER_SOFTWARE = "None"
def on_starting(server):
server.log.info("Starting Notifications API")
from gunicorn.http.wsgi import Response
original_init = Response.__init__
def custom_init(self, *args, **kwargs):
original_init(self, *args, **kwargs)
self.headers = [
(key, value) for key, value in self.headers if key.lower() != "server"
]
print(f"HEADERS {self.headers}")
Response.__init__ = custom_init
def worker_abort(worker):
@@ -32,23 +44,6 @@ def worker_int(worker):
worker.log.info("worker: received SIGINT {}".format(worker.pid))
# fix dynamic scan warning 10036
def post_fork(server, worker):
server.cfg.set(
"secure_scheme_headers",
{
"X-FORWARDED-PROTO": "https",
},
)
original_send = worker.wsgi.send
def custom_send(self, resp, *args, **kwargs):
resp.headers.pop("Server", None)
return original_send(resp, *args, **kwargs)
worker.wsgi.send = custom_send.__get__(worker.wsgi, type(worker.wsgi))
def fix_ssl_monkeypatching():
"""
eventlet works by monkey-patching core IO libraries (such as ssl) to be non-blocking. However, there's currently