-
Notifications
You must be signed in to change notification settings - Fork 7
Fix proxy lost log rotation, filling up disk and hogging CPU and RAM to parse large logs on restart #617
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
Closed
Closed
Fix proxy lost log rotation, filling up disk and hogging CPU and RAM to parse large logs on restart #617
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
aefcd89
proxy: enable built-in nginx logrotate config, will send our config i…
tlvu 4bf0ce0
proxy: rollback to same exising version because error
tlvu 77c457b
proxy: the entrypoint must ends with .sh
tlvu 852fdd0
proxy: override built-in logrotate config
tlvu e025b87
proxy: fix logrotate cron job do not fire
tlvu 6f8021f
Merge remote-tracking branch 'origin/master' into fix-nginx-proxy-mis…
tlvu 08739ef
proxy: use same retention as previous CanarieAPI
tlvu 1d8d962
proxy: correlate cron config with previous CanarieApi
tlvu 7f97c8b
proxy: add Dockerfile for custom Nginx image
tlvu aebcd90
CHANGES: fix proxy lost log rotation
tlvu e288e21
CHANGES: update proxy lost log rotation
tlvu c5edff2
CHANGES: proxy lost log rotation: wrong issue url
tlvu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Match previous CanarieApi https://github.com/Ouranosinc/CanarieAPI/blob/cc0ae59231ee4b58a34571bd12097c660aefb2e3/canarieapi-cron#L1 | ||
| * * * * * root /usr/sbin/logrotate -v /etc/logrotate.d/nginx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # docker buildx build -f Dockerfile . -t pavics/nginx-cron-logrotate:1.23.4-251205 --pull --no-cache | ||
| FROM nginx:1.23.4 | ||
|
|
||
| RUN apt-get update && \ | ||
| DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --no-install-suggests -y cron logrotate && \ | ||
| apt-get clean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # pavics/nginx-cron-logrotate | ||
|
|
||
| Official Nginx docker image with additional `cron` and `logrotate` installed so | ||
| Nginx can log to a file instead of to STDOUT as with the official Nginx image | ||
| default config. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Taken from Nginx docker image, tweaked lightly to match previous CanarieApi. | ||
|
|
||
| /var/log/nginx/*.log { | ||
| missingok | ||
| # https://github.com/Ouranosinc/CanarieAPI/blob/cc0ae59231ee4b58a34571bd12097c660aefb2e3/canarieapi/logparser.py#L15 | ||
| rotate 150 | ||
| compress | ||
| delaycompress | ||
| notifempty | ||
| create 640 nginx adm | ||
| sharedscripts | ||
| postrotate | ||
| if [ -f /var/run/nginx.pid ]; then | ||
| kill -USR1 `cat /var/run/nginx.pid` | ||
| fi | ||
| endscript | ||
| } |
17 changes: 17 additions & 0 deletions
17
birdhouse/components/proxy/nginx-docker-entrypoint.d/launch_cron.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/bin/sh -x | ||
|
|
||
| # Those config files need to have proper ownership and permissions, else the | ||
| # deamon will not run. | ||
| deploy_config() { | ||
| srcfile="$1" | ||
| destfile="$2" | ||
| cp -v "$srcfile" "$destfile" | ||
| chown root:root "$destfile" | ||
| chmod 644 "$destfile" | ||
| } | ||
|
|
||
|
|
||
| deploy_config /file/cron.d/logrotate /etc/cron.d/logrotate | ||
| deploy_config /file/logrotate.d/nginx /etc/logrotate.d/nginx | ||
|
|
||
| cron |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is built manually? Should it be configured automatically on docker hub?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes manually as this is a temporary work-around. Let's try to not make this too comfortable that it becomes a permanent solution.