SaaS CMS has officially launched! Learn more now.

Can we set database mode read-only programmatically without application recycling?


Can we set database mode read-only programmatically without application recycling? I don't want to use appsettings.

May 30, 2022 15:33

Hi, have you checked could you implement your own IDatabaseMode  (as the interface defines the DatabaseMode property as only get) and inheriting the default implementation and adding on top of that your own custom logic?

Jun 02, 2022 16:09

The question is a bit ambiguous. Technically, it is possible. It's just a value reading from appsettings. The internal DatabaseModeService class registered as singleton service does the actual job. In the real scenario, how would you prevent the current running application being interrupted or impacted while changing the value programmatically during the runtime?

Edited, Jun 03, 2022 3:15

Thanks, both for your responses.

Of course, I don't want to change app settings at runtime, as that means an application recycles but I want to achieve all the below functionalities. DatabaseModeService returns the status back but doesn't do the actual functionality.

In the ReadOnly mode, the application can only load data from the database. The following modules and functions are affected in the ReadOnly mode:

  • Scheduler Service is disabled.
  • Model synch is disabled.
  • Indexing of content is disabled.
  • User, role and claims synch are disabled.
  • Automatic database updating throws exception if updating is needed.
  • Statistics Logger is disabled.
  • Saving web.config file into database is disabled.
Jun 03, 2022 15:09

If I don't misunderstand your question, unfortunately, the IDatabaseMode is only used to fetch the static value from what I can see through ILSpy. Each functional areas you mentioned above has injected IDatabaseMode interface and program against the static value. E.g. the screenshot below is the Scheuler service-disabled function. 

Jun 06, 2022 5:39

:) my question is can we move/set EPi to read-only mode while the site is up & running without any disruption or recycling.

Jun 06, 2022 7:58
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.