I have setup Nginx with gunciron and django. Everything seems to work fine , atleast that what i believed. However , when i check the .gunicorn-logs directory as specified to be created in docker and specified the myscipt.sh below, it shows 2 files :
access.log with all the access to the gunciron server &
error.log which should be empty shows 1 kb of file.
Upon inspection, I get this inside --->
Gunicorn error.log file --->
[2024-12-05 04:36:15 +0000] [85] [INFO] Starting gunicorn 23.0.0
[2024-12-05 04:36:15 +0000] [85] [INFO] Listening at: http://0.0.0.0:8585 (85)
[2024-12-05 04:36:15 +0000] [85] [INFO] Using worker: gthread
[2024-12-05 04:36:15 +0000] [88] [INFO] Booting worker with pid: 88
[2024-12-05 04:36:15 +0000] [89] [INFO] Booting worker with pid: 89
[2024-12-05 04:36:15 +0000] [90] [INFO] Booting worker with pid: 90
[2024-12-05 04:36:15 +0000] [91] [INFO] Booting worker with pid: 91
Gunciron access.log file --->
49.xxx.xxx.xx - - [05/Dec/2024:10:06:26 +0530] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 4158 "-" "PostmanRuntime/7.43.0"
127.0.0.1 - - [05/Dec/2024:10:06:35 +0530] "GET /static/admin/ HTTP/1.1" 302 0 "-" "PostmanRuntime/7.43.0"
127.0.0.1 - - [05/Dec/2024:10:06:36 +0530] "GET /admin/login/?next=/static/admin/ HTTP/1.1" 200 4172 "http://34.xxx.xxx.xx:75/static/admin/" "PostmanRuntime/7.43.0"
127.0.0.1 - - [05/Dec/2024:10:06:42 +0530] "GET /static/admin/ HTTP/1.1" 302 0 "-" "PostmanRuntime/7.43.0"
127.0.0.1 - - [05/Dec/2024:10:06:42 +0530] "GET /admin/login/?next=/static/admin/ HTTP/1.1" 200 4172 "http://34.xxx.xxx.xx:75/static/admin/" "PostmanRuntime/7.43.0"
The nginx logs files has only access.log filled up and the error.log is empty.
Nginx access.log file ---->
49.xxx.xxx.xx - - [05/Dec/2024:04:36:35 +0000] "GET /static/admin/ HTTP/1.1" 302 0 "-" "PostmanRuntime/7.43.0" "-"
49.xxx.xxx.xx - - [05/Dec/2024:04:36:36 +0000] "GET /admin/login/?next=/static/admin/ HTTP/1.1" 200 1522 "http://34.xxx.xxx.xx:75/static/admin/" "PostmanRuntime/7.43.0" "-"
49.xxx.xxx.xx - - [05/Dec/2024:04:36:42 +0000] "GET /static/admin/ HTTP/1.1" 302 0 "-" "PostmanRuntime/7.43.0" "-"
49.xxx.xxx.xx - - [05/Dec/2024:04:36:42 +0000] "GET /admin/login/?next=/static/admin/ HTTP/1.1" 200 1526 "http://34.xxx.xxx.xx:75/static/admin/" "PostmanRuntime/7.43.0" "-"
Here is how i have define the gunicorn server related lines inside dockerFile.
RUN mkdir -p .gunicorn-logs
RUN touch /opt/.gunicorn-logs/error.log
RUN touch /opt/.gunicorn-logs/access.log
RUN chmod +x /opt/.gunicorn-logs/
cmd myscipt.sh
The myscript.sh where both nginx and gunciron get invoked --->
#!/bin/sh
nginx -g 'daemon off;' &
gunicorn mydjangoapi.wsgi:application --config=gunicorn_config_api-1.py
Finally , gunicorn_config_api-1.py part of root folder --->
bind = "0.0.0.0:8585"
loglevel = "INFO"
workers = "4"
threads="10"
reload = True
errorlog = "/opt/.gunicorn-logs/error.log"
accesslog = "/opt/.gunicorn-logs/access.log"