Jumoo / Our.Umbraco.MaintenanceMode

Put Umbraco Into Maintenance Mode - While you do things
15 stars 9 forks source link

V10 load balanced #44

Closed craigagnew closed 2 months ago

craigagnew commented 2 months ago

Resolves #33

Summary

This PR adds support for load balanced environments. It proposes the introduction of a few ideas:

Testing

How to test? Add the following to appsettings:

  "MaintenanceMode": {
    "StorageMode": "Database"
  }

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 :)

KevinJump commented 2 months ago

Thanks, this looks great, we will take a look this week, and see if we can get it merged and released 👍

henryjump commented 2 months ago

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.

craigagnew commented 2 months ago

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 😄

craigagnew commented 2 months ago

Anything else I can contribute for this one @henryjump @KevinJump?

henryjump commented 2 months ago

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

craigagnew commented 2 months ago

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?

KevinJump commented 2 months ago

Woot! -

Merged and in v10.2.0 release - https://www.nuget.org/packages/Our.Umbraco.MaintenanceMode/10.2.0