Skip to content

Commit 8a0d4b8

Browse files
committed
docs: add missing environment variable
1 parent 744e0d9 commit 8a0d4b8

File tree

4 files changed

+33
-32
lines changed

4 files changed

+33
-32
lines changed

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,20 @@ services:
5858
5959
## Environment variables
6060
61-
- `LOGS_DIRECTORIES` (required) — space separated directories to scan, e.g. "/var/log /var/lib/docker/containers"
62-
- `LOG_FILE_ENDINGS` — space separated file extensions (default: "log")
63-
- `LOGROTATE_INTERVAL` — hourly|daily|weekly|monthly|yearly (affects logrotate rules)
64-
- `LOGROTATE_CRONSCHEDULE` — cron expression for the schedule; default is suitable for interval
65-
- `LOGROTATE_COPIES` — number of rotated copies to keep (default 5)
66-
- `LOGROTATE_SIZE` — trigger rotate when file exceeds size (e.g. 100k, 10M)
67-
- `LOGROTATE_COMPRESSION` — set to "compress" to enable compression
68-
- `LOGROTATE_DELAYCOMPRESS` — "false" to disable default delaycompress (when compression enabled)
69-
- `LOGROTATE_MODE` — e.g. "create 0644" to change rotate mode (default: copytruncate)
70-
- `LOGROTATE_OLDDIR` — directory to move old logs into
71-
- `LOGROTATE_STATUSFILE` — path to logrotate status file
72-
- `LOGROTATE_PARAMETERS` — raw flags passed to logrotate (e.g. "vdf")
73-
- `LOGROTATE_PREROTATE_COMMAND` / `LOGROTATE_POSTROTATE_COMMAND` — scripts/commands to run
61+
- `LOGS_DIRECTORIES` (required) - space separated directories to scan, e.g. "/var/log /var/lib/docker/containers"
62+
- `LOG_FILE_ENDINGS` - space separated file extensions (default: "log")
63+
- `LOGROTATE_INTERVAL` - hourly|daily|weekly|monthly|yearly (affects logrotate rules)
64+
- `LOGROTATE_CRONSCHEDULE` - cron expression for the schedule; default is suitable for interval
65+
- `LOGROTATE_COPIES` - number of rotated copies to keep (default 5)
66+
- `LOGROTATE_SIZE` - trigger rotate when file exceeds size (e.g. 100k, 10M)
67+
- `LOGROTATE_COMPRESSION` - set to "compress" to enable compression
68+
- `LOGROTATE_DELAYCOMPRESS` - "false" to disable default delaycompress (when compression enabled)
69+
- `LOGROTATE_MODE` - e.g. "create 0644" to change rotate mode (default: copytruncate)
70+
- `LOGROTATE_OLDDIR` - directory to move old logs into
71+
- `LOGROTATE_STATUSFILE` - path to logrotate status file
72+
- `LOGROTATE_PARAMETERS` - raw flags passed to logrotate (e.g. "vdf")
73+
- `LOGROTATE_PREROTATE_COMMAND` / `LOGROTATE_POSTROTATE_COMMAND` - scripts/commands to run
74+
- `LOGROTATE_AUTOUPDATE` - regenerate logrotate configuration on each cron execution
7475

7576
## Examples & notes
7677

container-entrypoint.sh

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,18 @@ if [ -n "${DELAYED_START}" ]; then
1515
sleep ${DELAYED_START}
1616
fi
1717

18-
#Create Logrotate Conf
18+
# Create logrotate config
1919
source /usr/bin/logrotate.d/logrotate-create-config.sh
2020

2121
cat /usr/bin/logrotate.d/logrotate.conf
2222

23-
# ----- Crontab Generation ------
24-
23+
# Crontab Generation
2524
logrotate_parameters=""
26-
2725
if [ -n "${LOGROTATE_PARAMETERS}" ]; then
2826
logrotate_parameters="-"${LOGROTATE_PARAMETERS}
2927
fi
3028

3129
logrotate_cronlog=""
32-
3330
if [ -n "${LOGROTATE_LOGFILE}" ] && [ -z "${SYSLOGGER}"]; then
3431
logrotate_cronlog=" 2>&1 | tee -a "${LOGROTATE_LOGFILE}
3532
else
@@ -39,7 +36,6 @@ else
3936
fi
4037

4138
logrotate_croninterval="1 0 0 * * *"
42-
4339
if [ -n "${LOGROTATE_INTERVAL}" ]; then
4440
case "$LOGROTATE_INTERVAL" in
4541
hourly)
@@ -69,17 +65,27 @@ fi
6965

7066
logrotate_cron_timetable="/usr/sbin/logrotate ${logrotate_parameters} --state=${logrotate_logstatus} /usr/bin/logrotate.d/logrotate.conf ${logrotate_cronlog}"
7167

72-
# ----- Cron Start ------
73-
68+
# Cron Startup
7469
if [ "$1" = 'cron' ]; then
7570
if [ ${logrotate_autoupdate} = "true" ]; then
76-
exec /usr/bin/go-cron "${logrotate_croninterval}" /bin/bash -c "/usr/bin/logrotate.d/update-logrotate.sh; ${logrotate_cron_timetable}"
71+
mkdir -p /etc/ofelia
72+
cat <<EOF > /etc/ofelia/schedule-autoupdate.ini
73+
[job-local "logrotate-with-autoupdate"]
74+
schedule = ${logrotate_croninterval}
75+
command = /bin/bash -c \"/usr/bin/logrotate.d/update-logrotate.sh && ${logrotate_cron_timetable}\"
76+
EOF
77+
78+
exec ofelia daemon --config /etc/ofelia/schedule-autoupdate.ini
7779
exit
7880
fi
79-
80-
exec /usr/bin/go-cron "${logrotate_croninterval}" /bin/bash -c "${logrotate_cron_timetable}"
81+
mkdir -p /etc/ofelia
82+
cat <<EOF > /etc/ofelia/schedule-standard.ini
83+
[job-local "logrotate"]
84+
schedule = ${logrotate_croninterval}
85+
command = /bin/bash -c \"${logrotate_cron_timetable}\"
86+
EOF
87+
88+
exec ofelia daemon --config /etc/ofelia/schedule-standard.ini
8189
fi
8290

83-
#-----------------------
84-
8591
exec "$@"

ofelia/schedule-autoupdate.ini

Lines changed: 0 additions & 3 deletions
This file was deleted.

ofelia/schedule-standard.ini

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)