-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If the Nginx process dies I'm not sure what will happen #51
Comments
I was curious about this so I did a little investigating. If the nginx worker process dies it will get respawned by the nginx master (as you'd probably expect). If the nginx master process dies the worker will keep serving requests until it dies, but then won't be respawned. It's relatively straightforward to add a Docker diff --git a/Dockerfile b/Dockerfile
index a6f8ec6..ce16cce 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -24,10 +24,14 @@ RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC64107
&& adduser nginx django
COPY nginx/ /etc/nginx/
+RUN apt-get-install.sh curl
+
# Install gunicorn
COPY requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
+HEALTHCHECK --interval=5m --timeout=3s \
+ CMD ["curl", "--fail", "http://localhost:8000/", "||", "exit", "1"]
EXPOSE 8000
WORKDIR /app
|
@alexmuller thanks for looking into this. I did have a branch locally where our tests sent a The issue is that the container starts up like this:
So the Gunicorn master process ends up being the parent process of the Nginx master process. When the Nginx process quits the Gunicorn process doesn't care. I think the The proper solution to this is probably to not run more than one thing at a time in a container, and instead run Nginx in a separate container. But we're not really able to do that currently with MC2. So there should be something like this:
... that dies when any of its direct children dies and also proxies signals to those children. I haven't looked much into Docker healthchecks.. I always assumed that they were a Docker swarm thing. Additionally, these images don't have curl inside them. |
That makes sense, thanks for the detailed reply! I think you're right about the actual solution being to make the container simpler. |
We now have tests for this process structure. |
The Nginx process is just forked from the main one during startup, nothing manages it. I'm not sure exactly what will happen if something goes wrong with it.
Thankfully, Nginx is pretty reliable.
The text was updated successfully, but these errors were encountered: