From 329c1d931188e9f60f24f6954866256a82250d49 Mon Sep 17 00:00:00 2001 From: tschaffter Date: Fri, 4 Dec 2020 10:19:16 -0800 Subject: [PATCH] Update uwsgi config --- server/Dockerfile | 8 ++++++-- server/docker-entrypoint.sh | 2 +- server/openapi_server/__main__.py | 4 +--- server/uwsgi.ini | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/server/Dockerfile b/server/Dockerfile index 8d37fe3..eece362 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -32,5 +32,9 @@ EXPOSE 8080 # Set the entrypoint script and the default command run by the container ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["python", "-m", "openapi_server"] -# CMD ["uwsgi", "--ini", "uwsgi.ini", "--lazy", "--http-socket", ":8080"] \ No newline at end of file + +# Run server in development mode +# CMD ["python", "-m", "openapi_server"] + +# Run server in production mode +CMD ["uwsgi", "--ini", "uwsgi.ini", "--lazy", "--http", ":8080"] \ No newline at end of file diff --git a/server/docker-entrypoint.sh b/server/docker-entrypoint.sh index 3b6aa3b..b700f31 100644 --- a/server/docker-entrypoint.sh +++ b/server/docker-entrypoint.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -if [ "$1" = 'python' ]; then +if [ "$1" = 'uwsgi' ] || [ "$1" = 'python' ]; then cd ${APP_DIR} exec gosu www-data "$@" fi diff --git a/server/openapi_server/__main__.py b/server/openapi_server/__main__.py index 96f42da..a6ca0a2 100644 --- a/server/openapi_server/__main__.py +++ b/server/openapi_server/__main__.py @@ -10,9 +10,7 @@ app = connexion.App(__name__, specification_dir='./openapi/') app.app.json_encoder = encoder.JSONEncoder -app.add_api('openapi.yaml', - arguments={'title': 'NLP Sandbox Data Node API'}, - pythonic_params=True) +app.add_api('openapi.yaml', pythonic_params=True) # Configuring / to return the service information (required by NLP Sandbox) app.add_url_rule('/', 'root', lambda: flask.redirect('/api/v1/service')) diff --git a/server/uwsgi.ini b/server/uwsgi.ini index 2f48245..94bd762 100644 --- a/server/uwsgi.ini +++ b/server/uwsgi.ini @@ -12,4 +12,5 @@ master = true chmod-sock = 660 vacuum = true die-on-term = true -thunder-lock = true \ No newline at end of file +thunder-lock = true +http-keepalive = 1 \ No newline at end of file