Skip to content

Commit

Permalink
Dockerfile: manage container processes with 'supervisord' program
Browse files Browse the repository at this point in the history
  • Loading branch information
tmszi committed Mar 10, 2021
1 parent 413cdf9 commit dba7877
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ RUN cd bower_components/ol2/build/ && pipenv run python build.py -c none ../../.
RUN pipenv run python3 manage.py compress
RUN pipenv run python3 manage.py crontab add

USER root
RUN mkdir -p /var/log/supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

ENTRYPOINT ["./docker-entrypoint.sh"]
13 changes: 1 addition & 12 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
#!/bin/bash
echo Starting Gunicorn.
echo $DJANGO_SETTINGS_MODULE
exec pipenv run gunicorn wsgi:application \
--name mapapnk \
--bind 0.0.0.0:${GUNICORN_PORT:-"8000"} \
--workers ${GUNICORN_NUM_WORKERS:-"2"} \
--timeout ${GUNICORN_TIMEOUT:-"60"} \
--preload \
--log-level=debug \
--log-file=- \
--access-logfile=- \
"$@"
/usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf
11 changes: 11 additions & 0 deletions launch_gunicorn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
exec pipenv run gunicorn wsgi:application \
--name mapapnk \
--bind 0.0.0.0:${GUNICORN_PORT:-"8000"} \
--workers ${GUNICORN_NUM_WORKERS:-"2"} \
--timeout ${GUNICORN_TIMEOUT:-"60"} \
--preload \
--log-level=debug \
--log-file=- \
--access-logfile=- \
"$@"
20 changes: 20 additions & 0 deletions supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[supervisord]
nodaemon=true

[program:cron]
command=/usr/sbin/cron -f
autostart=true
autorestart=true
user=root
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log

[program:gunicorn]
command=/home/test/launch_gunicorn.sh
autostart=true
autorestart=true
user=test
directory=/home/test
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
environment=LC_ALL='en_US.UTF-8',LANG='en_US.UTF-8',HOME="/home/test",USER="test"

0 comments on commit dba7877

Please sign in to comment.