Closed craigagnew closed 2 months ago
Thanks, this looks great, we will take a look this week, and see if we can get it merged and released 👍
Hi
added a couple of changes
we think checking the server role to see if umbraco thinks it's running loadbalanced is more reliable than using the config settings, but if you think that's not right, please let us know.
Hi @henryjump
Using server role totally makes sense, I was looking for something that did exactly what you've got but couldn't find it so thanks!
And makes sense on the DB check to reduce the warnings 😄
Anything else I can contribute for this one @henryjump @KevinJump?
we wanted to have a cache for the database lookups so the database doesn't get hit for every request
so this version has a _lastChecked
value so that we only hit the database every n seconds.
the CacheSeconds
option sets how many seconds it waits, default is 30
"MaintenanceMode": {
"StorageMode": "Database",
"CacheSeconds": 30
}
on a local sever changes to and from maintenance mode happens instantly, but on remote servers it may take up to CacheSeconds
Umbraco does this for the cache on load balancing, but it checks every five seconds so maybe we could have the value lower
Good idea @henryjump.
I wonder, to make it clear it's only for use in Database
storage mode if we should name the setting WaitTimeBetweenDatabaseCalls
(riffing off Umbraco's DatabaseServerRegistrar.WaitTimeBetweenCalls
here).
Thoughts?
Woot! -
Merged and in v10.2.0 release - https://www.nuget.org/packages/Our.Umbraco.MaintenanceMode/10.2.0
Resolves #33
Summary
This PR adds support for load balanced environments. It proposes the introduction of a few ideas:
IStorageProvider
in the service code to access the appropriate place to read/write settingsDatabaseStorageProvider
for use in load balanced setupsTesting
How to test? Add the following to appsettings:
This will trigger the switch into database storage mode, observe that settings are written to and read from the database.
Note that without the app setting above, the code will attempt to determine whether Umbraco is in a load balanced setup and behave accordingly.
Also @KevinJump sorry it looks like a lot of files changed but there are a lot of one-liners in the notification handlers :)