···303303 }
304304305305 default:
306306+ // Hook a signal (SIGHUP on *nix, nothing on Windows) for reloading the configuration
307307+ // at runtime. This is useful because it preserves S3 backend cache contents. Failed
308308+ // configuration reloads will not crash the process; you may want to check the syntax
309309+ // first with `git-pages -config ... -print-config` since there is no other feedback.
310310+ OnReload(func() {
311311+ if newConfig, err := Configure(*configTomlPath); err != nil {
312312+ log.Println("config:", err)
313313+ log.Println("config: reload failed")
314314+ } else {
315315+ log.Println("config: reloaded")
316316+ // From https://go.dev/ref/mem:
317317+ // > A read r of a memory location x holding a value that is not larger than
318318+ // > a machine word must observe some write w such that r does not happen before
319319+ // > w and there is no write w' such that w happens before w' and w' happens
320320+ // > before r. That is, each read must observe a value written by a preceding or
321321+ // > concurrent write.
322322+ config = newConfig
323323+ }
324324+ })
325325+306326 // Start listening on all ports before initializing the backend, otherwise if the backend
307327 // spends some time initializing (which the S3 backend does) a proxy like Caddy can race
308328 // with git-pages on startup and return errors for requests that would have been served