forked from NOAA-OWP/ngencerf-server
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogrotate-ngencerf.dev.template
More file actions
84 lines (74 loc) · 3.05 KB
/
logrotate-ngencerf.dev.template
File metadata and controls
84 lines (74 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Logrotate config for ngencerf (development)
# Rotates logs in ./logs relative to the repo root.
# __LOG_DIR__ will be replaced by runCerf.sh with the actual repo path.
#
# NOTE: We use two separate stanzas (one per log file) instead of a
# single stanza listing both files. In practice, combining them caused
# only the first file to rotate consistently while the second (db log)
# was skipped. Keeping them separate ensures both files always rotate.
#
# To trigger manually in development:
# $ /usr/sbin/logrotate -s ~/.logrotate-status -f ./logrotate-ngencerf.dev.conf
#
# DIFFERENCES FROM PRODUCTION:
# - Uses copytruncate in development because both log writers keep their
# files open:
# * ngencerf.log is written through: exec > >(tee -a "$LOGFILE_DEV") 2>&1
# * ngencerf_db.log is written by Django logging.FileHandler
# Rename-and-recreate rotation would not work correctly unless each writer
# explicitly re-opened its log file.
# - Does NOT use create, because in this dev setup the existing log writers
# would continue writing to their already-open file descriptors after a
# rename-and-recreate rotation.
# - Does NOT use the Gunicorn postrotate USR1 signal block, because Gunicorn
# is not running in normal development mode.
# - Does NOT use "su root root", because this file must be generic for any
# developer account and should not assume root ownership.
# - Does NOT use minsize 10M, unlike production. In development, it is useful
# to allow scheduled rotations to occur consistently even when logs are small,
# so log history remains predictable during testing and debugging.
# - Keeps compression enabled in dev to reduce disk usage from repeated local
# rotations, since developers may generate logs quickly during iterative work.
# Rotate the main application log
__LOG_DIR__/ngencerf.log {
# always rotate when invoked (cron runs at 10:00 and 22:00)
daily
# keep 14 rotations
rotate 14
# don’t error if file missing
missingok
# don’t rotate empty logs
notifempty
# Truncate in place so the existing tee writer continues writing
# to the same file without needing a reopen signal or restart.
#
# DEV NOTE:
# copytruncate can theoretically lose a small amount of log output
# during the copy/truncate window, but it is the correct tradeoff
# for this local development setup.
copytruncate
# use date- and time-based rotation
dateext
dateformat _%Y-%m-%d_%H-%M
}
# Rotate the database log
__LOG_DIR__/ngencerf_db.log {
# always rotate when invoked (cron runs at 10:00 and 22:00)
daily
# keep 14 rotations
rotate 14
# gzip older logs
compress
# don’t compress the most recent rotated log
delaycompress
# don’t error if file missing
missingok
# don’t rotate empty logs
notifempty
# Truncate in place so Django's logging.FileHandler keeps writing
# to the same file without needing a reopen signal or process restart.
copytruncate
# use date- and time-based rotation
dateext
dateformat _%Y-%m-%d_%H-%M
}