Skip to content

Commit 756f354

Browse files
authored
Merge pull request #3383 from rommapp/fix-gunicorn-logs
fix(docker): generate gunicorn logging config to writable /tmp path
2 parents 9bafd11 + 3f52ab6 commit 756f354

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

  • docker/init_scripts

docker/init_scripts/init

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,18 @@ wait_for_gunicorn_socket() {
8888
fi
8989
}
9090

91-
# function that runs or main process and creates a corresponding PID file,
91+
# Function that runs our main process and creates a corresponding PID file
9292
start_bin_gunicorn() {
9393
# cleanup potentially leftover socket
9494
rm /tmp/gunicorn.sock -f
9595

96-
# Wire LOGLEVEL into Gunicorn's logging config so it respects the env var
96+
# Wire LOGLEVEL into Gunicorn's logging config so it respects the env var.
9797
local gunicorn_level="${LOGLEVEL^^}"
98-
sed -i '/\[logger_gunicorn\]/,/^\[/ s/^level=.*/level='"${gunicorn_level}"'/' /etc/gunicorn/logging.conf
98+
local gunicorn_log_config="/tmp/gunicorn/logging.conf"
99+
# Copy the config to a writable runtime path so this works on read-only root filesystems.
100+
mkdir -p /tmp/gunicorn
101+
cp /etc/gunicorn/logging.conf "${gunicorn_log_config}"
102+
sed -i '/\[logger_gunicorn\]/,/^\[/ s/^level=.*/level='"${gunicorn_level}"'/' "${gunicorn_log_config}"
99103

100104
# commands to start our main application and store its PID to check for crashes
101105
info_log "Starting backend"
@@ -118,7 +122,7 @@ start_bin_gunicorn() {
118122
--max-requests-jitter "${WEB_SERVER_MAX_REQUESTS_JITTER:-100}" \
119123
--worker-connections "${WEB_SERVER_WORKER_CONNECTIONS:-1000}" \
120124
--error-logfile - \
121-
--log-config /etc/gunicorn/logging.conf \
125+
--log-config "${gunicorn_log_config}" \
122126
main:app &
123127
}
124128

0 commit comments

Comments
 (0)