caddy
caddy copied to clipboard
Watch directory
Using this import example, loading a whole directory of config files, it would be nice if the --watch flag could monitor an entire directory as well. Being able to glob just like the import directive would be awesome as well.
One way this could be resolved is to always load + adapt the config file without looking at the main config file's modification time. This would definitely be more expensive though because it'll always be doing IO operations. But it might be worth doing 🤔
Hello, I've also stumbled across this.
I think such overhead will be negligible, moreover we can increase delay between reloads to, for example, 3 seconds instead of 1. But there are info messages printed every time config is loaded. If those can be removed, this would be good way to go.
Other approach is to look for import directives in Caddyfile and if they're pointing to files watch them too.
What do you think?
Us maintainers don't really have a need for this feature, so we don't have much motivation to work on it.
If someone wants to take a crack at it though, we'd be glad to review a PR.
Hi, I'm new to this repo I would like to tackle this issue.
I am a little confused on how to approach this, I thought maybe identify the folder of the import and watch them as well with time modification (it is also affected when files inside are affected) but how can I get the folder path inside?
That's part of the trouble. The caddyfile adapter would need to keep memory of all the locations it reads files from (including globs) and then set up file watching for all of them. File watching on all platforms Caddy supports is tricky though. Hence polling the Caddyfile adapter might be the simplest option even if inefficient.