Skip to content

Commit

Permalink
Added TRUNCATE_LOGS environ to reset all logs hourly
Browse files Browse the repository at this point in the history
  • Loading branch information
rgaudin committed Jun 24, 2022
1 parent 7f5a763 commit d9abfc1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ENV KB=kibiter-${KB_VERSION}
ENV KB_DIR=${KB}-linux-x86_64
ENV GITHUB_TOKEN=xxx
ENV GET="wget -q"
ENV TRUNCATE_LOGS ""

# install dependencies
RUN apt-get update && \
Expand Down Expand Up @@ -134,6 +135,7 @@ COPY config/aliases.json /aliases.json
COPY config/dashboard_overview.json /dashboard_overview.json
COPY config/logrotate /etc/logrotate.d/metrics

COPY bin/truncate-logs.sh /etc/cron.hourly/truncate-logs
COPY bin/entrypoint.sh /entrypoint.sh
RUN sudo chmod 755 /entrypoint.sh

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ Finaly, replace `config/dashboard_overview.json` by the new exported file.
- Initialization time : ~ 9 hours (cocom)
- Incremental update time : ~ 2 minutes (cocom)
- Elastic Search database size : ~ 8 Go

⚠️ A verbose log file at `/logs/all.log` grows indefinitely without a clear setting to control it. You may want to use `TRUNCATE_LOGS=y` environment variable to enable an hourly reset of all log files.
5 changes: 5 additions & 0 deletions bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ chown -R elasticsearch.elasticsearch /var/lib/elasticsearch
echo "Starting MariaDB"
/etc/init.d/mysql start

# Enable logs truncating
if [ ! -z "$TRUNCATE_LOGS" ]; then
chmod +x /etc/cron.hourly/truncate-logs
fi

# Start Cron
echo "Starting Cron"
/etc/init.d/cron start
Expand Down
6 changes: 6 additions & 0 deletions bin/truncate-logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

echo "truncating all logs…"
/usr/bin/truncate -s 0 /logs/all.log
/usr/bin/truncate -s 0 /var/log/*.log
/usr/bin/truncate -s 0 /var/log/**/*.log

0 comments on commit d9abfc1

Please sign in to comment.