Try our conversational search powered by Generative AI!

How to tell if the current instance is the scheduler app

Vote:
 

we are upgrading to CMS 12, previously we used 

EPiServer.Configuration.Settings.Instance.EnableScheduler

to tell if the current instance in DXC is the instance running the scheduler, we would like to do the same in the upgrade, but i cant find that property or an alternative in version 12.

Same question has asked about previous versions.

How can we programatically know if this is the instance in DXC running the scheduler. 

#313244
Nov 28, 2023 10:27
Vote:
 

In CMS 12 configuration settings are exposed as options classes which are already registered in the IOC container. 

I haven't tried this but you should be able to simply inject IOptions<SchedulerOptions> as such

public TestClass(IOptions<SchedulerOptions> options)
    {
        _options = options.Value;
    }

You can then use the value for _options.Enabled for your logic

See below documentation for details 

https://docs.developers.optimizely.com/content-management-system/docs/configuration

https://docs.developers.optimizely.com/content-management-system/docs/configuring-cms#scheduleroptions

#313245
Nov 28, 2023 11:37
Vote:
 

I can confirm this approach works.

In addition, there is a transformation step in the DXP deploy that force sets this value to Enabled = true for the scheduler instance and Enabled = false for all other instances (valid for preprod and prod), which means that you can trust this setting. If it is enabled, you're on the scheduler. Do note though that there is no scheduler instance in integration, but unless you deliberately change the value, it will be correct for integration too, since scheduler is by default enabled.

#314038
Edited, Dec 11, 2023 18:17
Vote:
 

To visualize what both Ronil and Johan said, check the scheduler property

Or if you prefer the programmatic approach

services.Configure<SchedulerOptions>(options =>
{
    options.Enabled = true;
});

And use something like this in your code

public class SchedulerEnabled
{
    private readonly IOptions<SchedulerOptions> _options;

    public SchedulerEnabled(IOptions<SchedulerOptions> options)
    {
        _options = options;
    }

    public bool Value { get { return _options.Value.Enabled; } }
}
#314075
Dec 11, 2023 23:12
* 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.