the log gets very spammy. Every second, there is a line like this:
2023/05/17 12:46:42.285 INFO using provided configuration {"config_file": "Caddyfile", "config_adapter": ""}
2023/05/17 12:46:43.291 INFO using provided configuration {"config_file": "Caddyfile", "config_adapter": ""}
2023/05/17 12:46:44.287 INFO using provided configuration {"config_file": "Caddyfile", "config_adapter": ""}
caddy version: v2.7.0-beta.1
As a result of #5521 running caddy per
caddy run --watchthe log gets very spammy. Every second, there is a line like this:
Even relatively easy Caddyfiles are not always byte-equal after loading, which is why it is reloaded very often even though there are no changes. This line is the culprit https://github.com/caddyserver/caddy/blob/v2.7.0-beta.1/cmd/main.go#L224
Example Caddyfile:
lastCfg contents:
{"logging":{"logs":{"default":{"encoder":{"format":"console","level_format":"upper","time_format":"wall_milli","time_local":true}}}},"apps":{"http":{"servers":{"srv0":{"listen":[":443"],"routes":[{"handle":[{"handler":"vars","root":"."},{"browse":{},"handler":"file_server","hide":[".\\Caddyfile",".\\Caddyfile:22 (import config)"]}]}]},"srv1":{"listen":[":80"],"routes":[{"handle":[{"handler":"vars","root":"."},{"browse":{},"handler":"file_server","hide":[".\\Caddyfile:17 (import config)"]}]}]}}},"tls":{"automation":{"policies":[{"issuers":[{"module":"internal"}]}]}}}}newCfg contents:
{"logging":{"logs":{"default":{"encoder":{"format":"console","level_format":"upper","time_format":"wall_milli","time_local":true}}}},"apps":{"http":{"servers":{"srv0":{"listen":[":443"],"routes":[{"handle":[{"handler":"vars","root":"."},{"browse":{},"handler":"file_server","hide":[".\\Caddyfile:22 (import config)",".\\Caddyfile"]}]}]},"srv1":{"listen":[":80"],"routes":[{"handle":[{"handler":"vars","root":"."},{"browse":{},"handler":"file_server","hide":[".\\Caddyfile:17 (import config)"]}]}]}}},"tls":{"automation":{"policies":[{"issuers":[{"module":"internal"}]}]}}}}The difference is in
file_servers hide field. The json array does not always seems to have the same order.I don't really like the changes in #5521. Rereading the config every second is very inefficient. Isn't there a more efficient way like keeping track of all modification times of imported config files and the Caddyfile itself or using filesystem watchers (e.g https://github.com/fsnotify/fsnotify)?