Skip to content

Commit 7a53880

Browse files
authored
Revert "fix(otel-collector): fix log rotation script (#1479)" (#1495)
This reverts commit 0b19f91.
1 parent 2c3f31b commit 7a53880

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

docker/otel-collector/log-rotator.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,24 @@ echo "Settings: Max size=${MAX_SIZE_MB}MB, Max archives=${MAX_ARCHIVES}, Check i
2222

2323
while true; do
2424
sleep "$CHECK_INTERVAL"
25-
25+
2626
if [ -f "$LOG_FILE" ]; then
2727
SIZE=$(stat -c%s "$LOG_FILE" 2>/dev/null || stat -f%z "$LOG_FILE" 2>/dev/null || echo 0)
28-
28+
2929
if [ "$SIZE" -gt "$MAX_SIZE_BYTES" ]; then
3030
echo "Rotating $LOG_FILE (size: $SIZE bytes)"
31-
31+
3232
# Rotate existing archives
3333
for i in $(seq $((MAX_ARCHIVES - 1)) -1 1); do
3434
if [ -f "${LOG_FILE}.${i}" ]; then
3535
mv "${LOG_FILE}.${i}" "${LOG_FILE}.$((i + 1))"
3636
fi
3737
done
38-
39-
# Move current log to .1 using an atomic operation. Then send SIGHUP to the
40-
# collector to refresh the config and reopen the default log file.
41-
mv "$LOG_FILE" "${LOG_FILE}.1"
42-
fuser -k -HUP "${LOG_FILE}.1"
43-
38+
39+
# Move current log to .1
40+
cp "$LOG_FILE" "${LOG_FILE}.1"
41+
> "$LOG_FILE" # Truncate the original file
42+
4443
# Remove oldest archive if it exists
4544
if [ -f "${LOG_FILE}.${MAX_ARCHIVES}" ]; then
4645
rm "${LOG_FILE}.${MAX_ARCHIVES}"

0 commit comments

Comments
 (0)