Commit b4c49d8d authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

use gunicorn on kubernetes

parent 6e951fff
Pipeline #20285 passed with stages
in 2 minutes and 43 seconds
......@@ -5,7 +5,7 @@ ENV PYTHONUNBUFFERED 1
# Install pipenv
RUN pip install pipenv
RUN apt update && apt install vim cron -y
RUN apt update && apt install vim -y
WORKDIR /code
RUN rm -rf Dockerfile
......
import logging
from rest_framework import permissions
from rest_framework.response import Response
from rest_framework.status import HTTP_500_INTERNAL_SERVER_ERROR
......@@ -8,6 +10,8 @@ from metagenedb.apps.catalog.management.commands.compute_stats import (
ComputeCounts, ComputeGeneLength, ComputeTaxonomyRepartition
)
logger = logging.getLogger(__name__)
class AdminCommandsAPI(APIView):
authentication_classes = [JSONWebTokenAuthentication]
......@@ -24,7 +28,8 @@ class ComputeStatisticsAPI(AdminCommandsAPI):
self.compute_class().all()
# ComputeGeneLength().all()
# ComputeTaxonomyRepartition().all()
except Exception:
except Exception as exception:
logger.warning(exception)
return Response({"message": self.error_message},
status=HTTP_500_INTERNAL_SERVER_ERROR)
return Response({"message": self.success_message})
......
......@@ -150,3 +150,22 @@ SECRET_KEY = env.str('SECRET_KEY', default='')
# -- key for API when additional information is added to the payload
API_KEY_ADDITIONAL_INFO = env.str('API_KEY_ADDITIONAL_INFO', default='metagenedb_additional_info')
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'loggers': {
'django': {
'handlers': ['console'],
'level': env.str('DJANGO_LOG_LEVEL', 'INFO'),
},
'metagenedb': {
'level': env.str('DJANGO_LOG_LEVEL', 'INFO'),
},
},
}
......@@ -7,4 +7,4 @@ if [ -z $PORT ];then PORT=8000;fi # Need to fix to get value from .env file
python ${SCRIPTS_PATH}/manage.py collectstatic --no-input
python ${SCRIPTS_PATH}/manage.py makemigrations
python ${SCRIPTS_PATH}/manage.py migrate
python ${SCRIPTS_PATH}/manage.py runserver 0.0.0.0:${PORT}
gunicorn metagenedb.wsgi:application --capture-output --bind 0.0.0.0:${PORT}
......@@ -15,7 +15,7 @@ services:
DEBUG: "true"
depends_on:
- postgresql
command: /code/scripts/start_dev.sh
command: /code/scripts/start.sh
networks:
- main
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment