Skip to content

Commit fd55e41

Browse files
Trigger certificate reload on the REMOVE event
Each time a certificate is renewed, there's a series of file system events (CREATE, CHMOD, CREATE, RENAME, CREATE and REMOVE). Write doesn't trigger cert reload for some reason, hence the change
1 parent b0c15af commit fd55e41

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

main.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ func (cw *CertWatcher) Watch() error {
9797
if !ok {
9898
return errors.New("watcher channel closed")
9999
}
100-
if event.Op&fsnotify.Write == fsnotify.Write {
100+
// Each time a certificate is renewed, there's a series of file system events (CREATE, CHMOD, CREATE, RENAME, CREATE and REMOVE)
101+
// Trigger certificate reload on the last event: REMOVE
102+
if event.Op&fsnotify.Remove == fsnotify.Remove {
101103
log.Info().Msg("Certificate files modified. Reloading...")
102104
if err := cw.loadCertificate(); err != nil {
103105
log.Error().Err(err).Msg("Failed to reload certificate")

0 commit comments

Comments
 (0)