caddy icon indicating copy to clipboard operation
caddy copied to clipboard

Watch directory

Open p3lim opened this issue 5 years ago • 2 comments

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.

p3lim avatar Jun 22 '20 16:06 p3lim

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 🤔

francislavoie avatar Feb 22 '21 07:02 francislavoie

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?

KoHcoJlb avatar Jun 23 '22 11:06 KoHcoJlb

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.

francislavoie avatar Oct 03 '22 04:10 francislavoie

Hi, I'm new to this repo I would like to tackle this issue.

jonatan5524 avatar May 06 '23 09:05 jonatan5524

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?

jonatan5524 avatar May 06 '23 11:05 jonatan5524

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.

francislavoie avatar May 06 '23 13:05 francislavoie