-
-
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
Constant reloading of configfile in 2.7.4 #5789
Comments
Thanks for opening an issue! We'll look into this. It's not immediately clear to me what is going on, so I'll need your help to understand it better. Ideally, we need to be able to reproduce the bug in the most minimal way possible using the latest version of Caddy. This allows us to write regression tests to verify the fix is working. If we can't reproduce it, then you'll have to test our changes for us until it's fixed -- and then we can't add test cases, either. I've attached a template below that will help make this easier and faster! This will require some effort on your part -- please understand that we will be dedicating time to fix the bug you are reporting if you can just help us understand it and reproduce it easily. This template will ask for some information you've already provided; that's OK, just fill it out the best you can. 👍 I've also included some helpful tips below the template. Feel free to let me know if you have any questions! Thank you again for your report, we look forward to resolving it! Template
Instructions -- please heed otherwise we cannot help you (help us help you!)
Example of a tutorial: Create a config file: |
1. Environment1a. Operating system and version
1b. Caddy version (run
|
Thanks, we'll look into this as soon as we have a chance! |
Wouldn't it be better to check for config file modification time and then load the config cfgFileInfo, err := os.Stat(filename)
// check err
lastModTime := cfgFileInfo.ModTime()
// load config
// begin poller
for range time.Tick(1 * time.Second) {
cfgFileInfo, err = os.Stat(filename)
// check err
if !cfgFileInfo.ModTime().After(lastModTime) {
continue
}
lastModTime = cfgFileInfo.ModTime()
// load config
} |
@amis-shokoohi the problem is a Caddyfile may import other files. We'd need to check the mod time for all files in the tree. We don't have infrastructure for tracking all the files that are imported currently. |
There was something with included files and inotify having issues with big
directories and such. That's what I read from the related ticket.
A different implementation for watching maybe on the horizon, maybe not .
But I'd like to have this fixed before they though (but I have nothing to
complain about ofcourse !)
…On Mon, Sep 4, 2023, 18:30 Amis Shokoohi ***@***.***> wrote:
Wouldn't it be better to check for config file modification time and then
load the config
rather than loading the config and checking its content.
https://github.com/caddyserver/caddy/blob/master/cmd/main.go#L189
I don't know if this is going to fix the issue though:
cfgFileInfo, err := os.Stat(filename)// check err
lastModTime := cfgFileInfo.ModTime()
// load config
// begin pollerfor range time.Tick(1 * time.Second) {
cfgFileInfo, err = os.Stat(filename)
// check err
if !cfgFileInfo.ModTime().After(lastModTime) {
continue
}
lastModTime = cfgFileInfo.ModTime()
// load config
}
—
Reply to this email directly, view it on GitHub
<#5789 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALMD2DQOHWMQ42KUXSOMS4LXYX62PANCNFSM6AAAAAA4C66CPU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I didn't see this: #5521 |
The morning is just starting here , so will try somewhere during the day !
…On Fri, Oct 6, 2023, 05:00 Francis Lavoie ***@***.***> wrote:
Sorry for the wait. @jorismak <https://github.com/jorismak> can you try
building from #5860 <#5860> to
confirm this fixes it for you?
—
Reply to this email directly, view it on GitHub
<#5789 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALMD2DXRKCTTF7FT4VJ7ZN3X55X3LAVCNFSM6AAAAAA4C66CPWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBZHEYTQNBUHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
First reports (had to figure out how to build it 😉 ) but it looks stable! I've put my Caddyfile back with those multiple hosts in one server block and I don't get rebuilds every few seconds. Feel free to close if you think this is enough testing :). Thanks! |
I think I'm now experiencing same issue. Caddy keeps reloading config everi few seconds. Tried on 2.7.3, 2.7.4, 2.7.5. Not sure if it was since long time o triggered by some recent caddyfile change. |
Do you use a caddyfile as config ?
Caddy writes its internal JSON config somewhere.
I'd it restarts , copy it quickly to a file to keep it. Do that every time
it restarts , see if you can find the differences. Then you know where
something changes in your config :).
Caddy loads the caddyfile every few seconds, parses the config , and if
it's different to the previous config , reloads and uses it. Something like
that.
If there are arrays that are constantly changing order , you'll have your
answer.
…On Fri, Dec 1, 2023, 22:13 outofsight ***@***.***> wrote:
I think I'm now experiencing same issue. Caddy keeps reloading config
everi few seconds. Tried on 2.7.3, 2.7.4, 2.7.5.
—
Reply to this email directly, view it on GitHub
<#5789 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALMD2DQO2PEMZA73ERBZDDDYHJB7FAVCNFSM6AAAAAA4C66CPWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZWG44DIMRXG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Yes, I use a caddyfile. I can see an autosave.json in the mounted config directory, but it doesn't appear changing (based on datetime) at least. Is this one or I have to search elsewhere? |
Yeah that one was changing for me . Take a copy everytime caddy reloads and
compare the contents.
If there are no differences, you have an entire different reason for your
restarting (another bug, user error , ....). Best to create a separate
issue for it then .
…On Sat, Dec 2, 2023, 01:00 outofsight ***@***.***> wrote:
Yes, I use a caddyfile. I can see an autosave.json in the mounted config
directory, but it doesn't appear changing (based on datetime) at least. Is
this one or I have to search elsewhere?
—
Reply to this email directly, view it on GitHub
<#5789 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALMD2DSBXR7ZWI6RJMT2I4TYHJVTJAVCNFSM6AAAAAA4C66CPWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZWHEZTSMBVGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Just upgraded from caddy 2.5-ish I guess, to 2.7.4.
I get the constant reloaded from config file as well now.
Dumping the autosave.json through
jq
and to different files and then looking at the differences,it appears there is another 'undeterministic' problem in the vhost names.
In my caddyfile:
(there is a lot more, but this is the culprit)
Originally posted by @jorismak in #5538 (comment)
The text was updated successfully, but these errors were encountered: