Add gunicorn to web server#9
Conversation
|
Quick question: why port 8001? |
|
Hi @dcgoss! |
|
@dcgoss do you want to take the lead reviewing / approving / merging this PR? |
| @@ -0,0 +1,4 @@ | |||
| #!/bin/bash -x | |||
|
|
|||
| manage.py migrate -v3 --no-input | |||
There was a problem hiding this comment.
What does -v3 do? Also, this command must be prefaced with python, like line 4
| command=/usr/local/bin/gunicorn task_service.wsgi:application -c /code/config/prod/gunicorn.conf | ||
| directory=/code | ||
| ; User account with minimal privileges | ||
| user=nobody |
There was a problem hiding this comment.
Does the nobody user need to be created in the Dockerfile (something like: RUN useradd nobody), or is that not needed?
|
|
||
| # Application is configured to run under Supervisord, which in turn monitors | ||
| # the Gunicorn web server | ||
| supervisord -c /code/config/prod/supervisord.conf |
There was a problem hiding this comment.
Just an idea, we could add a -n here to make supervisord run in the foreground since it is a container. Might make it easier to debug startup problems.
| worker_class = 'eventlet' | ||
|
|
||
| # Rule of thumb for workers is (2 * ncpus) + 1 | ||
| # http://docs.gunicorn.org/en/stable/design.html#how-many-workers |
There was a problem hiding this comment.
Gunicorn also supports supplying a Python file for configuration, here's an example from one of my projects. One benefit of this is you can dynamically compute the worker count when Gunicorn starts regardless of server, by using Python's multiprocessing.cpu_count
|
@kurtwheeler will this PR break anything in |
|
I'm not familiar with gunicorn so I'm not too sure. As long as this doesn't change the way the app is started or what ports need to be available it should be fine though. |
Motivation
Closes #8
I only copy the idea of this pr cognoma/core-service#48 here.
API changes
I don't make any change in API.
Implementation Notes
Add gunicorn to web server in production.
Functional Tests
Verify if is possible access API after start a container from docker run.