From 2eb02c4a5668a199867f64e6ae01c57aaab4f1a9 Mon Sep 17 00:00:00 2001 From: Michael Barroco Date: Thu, 17 Aug 2023 23:50:27 +0200 Subject: [PATCH 1/3] [wsgi] Replace gunicorn by waitress --- monitoring/mock_uss/gunicorn.conf.py | 59 ---------------------------- monitoring/mock_uss/start.sh | 9 +---- requirements.txt | 3 +- 3 files changed, 4 insertions(+), 67 deletions(-) delete mode 100644 monitoring/mock_uss/gunicorn.conf.py diff --git a/monitoring/mock_uss/gunicorn.conf.py b/monitoring/mock_uss/gunicorn.conf.py deleted file mode 100644 index fbb3b140fd..0000000000 --- a/monitoring/mock_uss/gunicorn.conf.py +++ /dev/null @@ -1,59 +0,0 @@ -import os - -from gunicorn.arbiter import Arbiter -from gunicorn.http import Request -from gunicorn.http.wsgi import Response -from gunicorn.workers.base import Worker -from loguru import logger - -from monitoring.mock_uss import webapp - - -def on_starting(server: Arbiter): - """gunicorn server hook called just before master process is initialized.""" - logger.debug("on_starting") - webapp.setup() - - -def when_ready(server: Arbiter): - """gunicorn server hook called just after the server is started.""" - logger.debug("when_ready") - webapp.start_periodic_tasks_daemon() - - -def pre_request(worker: Worker, req: Request): - """gunicorn server hook called just before a worker processes the request.""" - logger.debug( - "gunicorn pre_request from worker {} (OS PID {}): {} {}", - worker.pid, - os.getpid(), - req.method, - req.path, - ) - - -def post_request(worker: Worker, req: Request, environ: dict, resp: Response): - """gunicorn server hook called after a worker processes the request.""" - logger.debug( - "gunicorn post_request from worker {} (OS PID {}): {} {} -> {}", - worker.pid, - os.getpid(), - req.method, - req.path, - resp.status_code, - ) - - -def worker_abort(worker: Worker): - """gunicorn server hook called when a worker received the SIGABRT signal.""" - logger.debug( - "gunicorn worker_abort from worker {} (OS PID {})", worker.pid, os.getpid() - ) - - -def on_exit(server: Arbiter): - """gunicorn server hook called just before exiting Gunicorn.""" - logger.debug( - f"on_exit from process {os.getpid()} with arbiter process {server.pid}" - ) - webapp.shutdown(None, None) diff --git a/monitoring/mock_uss/start.sh b/monitoring/mock_uss/start.sh index db59b9ffeb..65f9da038e 100755 --- a/monitoring/mock_uss/start.sh +++ b/monitoring/mock_uss/start.sh @@ -19,10 +19,5 @@ cp health_check.sh /app # Start mock_uss server on port 5000 export PYTHONUNBUFFERED=TRUE -gunicorn \ - --preload \ - --config ./gunicorn.conf.py \ - --workers=4 \ - --threads=2 \ - --bind=0.0.0.0:5000 \ - monitoring.mock_uss:webapp +waitress-serve --listen=*:5000 \ + monitoring.mock_uss:webapp \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index fe315ef426..4cf6656a13 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ Flask-HTTPAuth==4.7.0 # atproxy geojson===2.5.0 # uss_qualifier google-auth==1.6.3 graphviz==0.20.1 # uss_qualifier -gunicorn==20.1.0 +gunicorn==20.1.0 # atproxy implicitdict==2.2.1 itsdangerous==2.0.1 # Version 2.1.0 is not compatible with flask 1.1.2. Jinja2==3.0.3 # See https://github.com/interuss/dss/issues/745 @@ -39,4 +39,5 @@ shapely==1.7.1 structlog==21.5.0 # deployment_manager termcolor==1.1.0 uas_standards==1.3.0 +waitress==2.1.2 # mock_uss Werkzeug==2.0.3 # See https://github.com/interuss/dss/issues/753 From 592c40339d1bd30a3255478a93926a619ad445f1 Mon Sep 17 00:00:00 2001 From: Michael Barroco Date: Fri, 18 Aug 2023 00:09:12 +0200 Subject: [PATCH 2/3] Augment logs --- monitoring/mock_uss/start.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/monitoring/mock_uss/start.sh b/monitoring/mock_uss/start.sh index 65f9da038e..2364726215 100755 --- a/monitoring/mock_uss/start.sh +++ b/monitoring/mock_uss/start.sh @@ -20,4 +20,6 @@ cp health_check.sh /app # Start mock_uss server on port 5000 export PYTHONUNBUFFERED=TRUE waitress-serve --listen=*:5000 \ + --log-socket-errors \ + --expose-tracebacks \ monitoring.mock_uss:webapp \ No newline at end of file From 6c1292628a5fb8f38a9125e7403680b51949bb25 Mon Sep 17 00:00:00 2001 From: Michael Barroco Date: Fri, 18 Aug 2023 00:23:14 +0200 Subject: [PATCH 3/3] Improve logs --- monitoring/mock_uss/stop_all_local_mocks.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/monitoring/mock_uss/stop_all_local_mocks.sh b/monitoring/mock_uss/stop_all_local_mocks.sh index f3cd3745af..db0405c9d3 100755 --- a/monitoring/mock_uss/stop_all_local_mocks.sh +++ b/monitoring/mock_uss/stop_all_local_mocks.sh @@ -16,6 +16,11 @@ if [ "$RID_VERSION" = "F3411-19" ]; then RID_EXT="_v19" fi +echo "LOGS\n========== A" +docker logs mock_uss_scdsc_a +echo "========== B" +docker logs mock_uss_scdsc_b + docker container rm -f \ mock_uss_scdsc_a \ mock_uss_scdsc_b \