261016.21 · 7f3683e7ac28b7a515031562ef675e6f6c8f1050
Log every action to the journal
mdserve now logs each run with its arguments, directory and binary, each server's start and stop with the cause, trees joining and leaving, stale locks cleared, page requests and faults. A later look at the log shows what happened when mdserve seems to misbehave, such as a stale server on another port answering for a page.
Entries go to the systemd journal under the tag mdserve, with the endpoint and priority as fields, so journalctl filters them. Where no journal runs they go to a file in the state directory, rotated at 1 MB. A detached server's stderr goes to the same place, so a panic is kept; before, it went nowhere.
Logging is always on, with no flag and no levels: a filter set before a mistake drops the entry that would explain it. Secret tokens stay out.
reading declarations
Changes to watch.go. All files
@@ -38,6 +38,7 @@ func newWatcher(mask uint32) *watcher { w := &watcher{fd: -1, mask: mask, wake: make(chan struct{}, 1)} fd, err := inotifyInit(syscall.IN_NONBLOCK | syscall.IN_CLOEXEC) if err != nil {+ logErr("inotify unavailable, polling every second: %v", err) w.poll.Store(true) return w }@@ -78,7 +79,9 @@ func (w *watcher) add(dir string) int { return -1 } if err != nil {- w.poll.Store(true)+ if !w.poll.Swap(true) {+ logErr("cannot watch %s, polling every second: %v", dir, err)+ } return -1 } return wd