Skip to content

Commit

Permalink
Trigger certificate reload on the REMOVE event
Browse files Browse the repository at this point in the history
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
  • Loading branch information
andreistefanzx authored Aug 12, 2024
1 parent b0c15af commit fd55e41
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ func (cw *CertWatcher) Watch() error {
if !ok {
return errors.New("watcher channel closed")
}
if event.Op&fsnotify.Write == fsnotify.Write {
// Each time a certificate is renewed, there's a series of file system events (CREATE, CHMOD, CREATE, RENAME, CREATE and REMOVE)
// Trigger certificate reload on the last event: REMOVE
if event.Op&fsnotify.Remove == fsnotify.Remove {
log.Info().Msg("Certificate files modified. Reloading...")
if err := cw.loadCertificate(); err != nil {
log.Error().Err(err).Msg("Failed to reload certificate")
Expand Down

0 comments on commit fd55e41

Please sign in to comment.