-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Add ability to periodically pull config #4106
Comments
Wanted to quickly follow up on this since I needed this feature for the project I've been working on. I can spare some time to submit a PR over the weekend. I had two proposals in mind 1] Change the function signature of the
|
Thanks for the proposals. I don't especially love either of them yet (need more time to think about it) -- but first, I have a question:
Did you mean the I'll need to spend some time deciding how the receiving side of the configs would be best architected. |
Yes. I meant LoadConfig. My bad. I just feel using a channel would provide maximum flexibility here. The only downside is that we won't be able to handle errors if any. To overcome that we can use a callback instead of a channel. |
I'll circle back around to this sometime after after the 2.4 release. 👍 |
Hi @mholt. I was wondering if we could circle back to this issue now? I don't mind contributing this feature since I will be needing it |
I don't think we should change the exported API. Currently, recursive config loads are disallowed to prevent accidental (and tight) infinite loops. But this could be a useful way to implement periodic pulling: simply pull a config that is itself configured to pull a config also. This way, pulling could be terminated simply by receiving a config that isn't configured to pull again. Of course, we'd have to avoid tight looping by implementing a timer. We could then allow recursive config pulling if there's also a timer configured. If you need this feature, want to try implementing this and let us know if it works? I think the right place for the timer duration is a new field in Lines 97 to 112 in 2de7e14
Aside from implementing the timer, you'll need to adjust these lines: Lines 262 to 273 in 2de7e14
to allow recursive pulling if a duration greater than zero is configured. That should probably be all that is needed. |
I see what you are suggesting. I do have some questions however. When will the subsequent call to this API happen? Are we suggesting a goroutine will go off if we encounter a timer value greater than zero? We'll call the exported API once the timer expires? Or should we simply block the current routine. Also? What if a call to the admin API is made while the timer is active? Do we want to account for that? Cause that could potentially lead to two active timers ticking simultaneously in separate routines. |
Good questions. Yeah, if a timer duration is specified, then the loading of the config will need to be done in a goroutine so that the timer can block the config load without blocking the rest of the server. At a glance, I imagine the timer will be inserted in here: Lines 477 to 500 in 2de7e14
probably right before L483 (
Also a great question - a goroutine should never be started without knowing how it will stop. Fortunately, we have a caddy/modules/caddyhttp/reverseproxy/reverseproxy.go Lines 764 to 769 in 7c68809
|
Got it. Will try to submit a PR over the weekend. |
Any progress on this? We need this feature too, and I would like to help |
mostly referenced to the issue re caddyserver#4106
* feat: implement a simple timer to pull config mostly referenced to the issue re #4106 * Update admin.go use `caddy.Duration` Co-authored-by: Matt Holt <[email protected]> * Update caddy.go Co-authored-by: Matt Holt <[email protected]> * Update admin.go Co-authored-by: Francis Lavoie <[email protected]> * fix: sync load config when no pull interval provided try not to make break change * fix: change PullInterval to LoadInterval * fix: change pull_interval to load_interval * Update caddy.go Co-authored-by: Matt Holt <[email protected]> Co-authored-by: Matt Holt <[email protected]> Co-authored-by: Francis Lavoie <[email protected]>
I think we can close this, it's been implemented in #4246. This will land in v2.4.4! |
This is a follow up request to #3994 - Dynamic config loading at startup.
Currently the config loading is a startup activity. As suggested in the PR, it would be great if we could pull this config periodically at a configurable time interval.
The text was updated successfully, but these errors were encountered: