[GH-ISSUE #582] Handle log file rotation, for example on SIGHUP #343

Closed
opened 2026-04-08 16:52:12 +03:00 by zhus · 1 comment
Owner

Originally created by @g-v-egidy on GitHub (May 11, 2025).
Original GitHub issue: https://github.com/sigoden/dufs/issues/582

Specific Demand

When dufs is running for a longer time you may want to rotate it's logfile. Optimally without interrupting service. There should either be a way to notify dufs about the logfile rotation or it should find out itself automatically.

dufs --log-file ./test.log . &
curl -o /dev/null --silent http://127.0.0.1:5000/
cat test.log
mv test.log test2.log
curl -o /dev/null --silent http://127.0.0.1:5000/

cat test.log
# this now returns: cat: test.log: No such file or directory

cat test2.log
# this shows both requests and not just the first one

pkill -HUP dufs
[1]+  Hangup                  dufs --log-file ./test.log .
# the dufs process is terminated at this point, as there is no SIGHUP handler implemented yet.

Implement Suggestion

It is very common for daemons to reopen the logfile on receiving a SIGHUP signal.

Another way would be to stat the log filename before logging each entry and comparing it with the inode of the opened logfile to detect a change.

But there are probably other ways for detecting log file rotation too.

Originally created by @g-v-egidy on GitHub (May 11, 2025). Original GitHub issue: https://github.com/sigoden/dufs/issues/582 ## Specific Demand When dufs is running for a longer time you may want to rotate it's logfile. Optimally without interrupting service. There should either be a way to notify dufs about the logfile rotation or it should find out itself automatically. ``` dufs --log-file ./test.log . & curl -o /dev/null --silent http://127.0.0.1:5000/ cat test.log mv test.log test2.log curl -o /dev/null --silent http://127.0.0.1:5000/ cat test.log # this now returns: cat: test.log: No such file or directory cat test2.log # this shows both requests and not just the first one pkill -HUP dufs [1]+ Hangup dufs --log-file ./test.log . # the dufs process is terminated at this point, as there is no SIGHUP handler implemented yet. ``` ## Implement Suggestion It is very common for daemons to reopen the logfile on receiving a SIGHUP signal. Another way would be to stat the log filename before logging each entry and comparing it with the inode of the opened logfile to detect a change. But there are probably other ways for detecting log file rotation too.
zhus closed this issue 2026-04-08 16:52:12 +03:00
Author
Owner

@sigoden commented on GitHub (May 12, 2025):

dufs is just a simple file server, and we don't think it's necessary to support such complex logging features.

<!-- gh-comment-id:2870284753 --> @sigoden commented on GitHub (May 12, 2025): dufs is just a simple file server, and we don't think it's necessary to support such complex logging features.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sigoden/dufs#343