Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Support for multi location application deployment #6752


User avatar
0
ajayak created

Does ASPNET Core support deployment at multiple locations? Will it work out of the box for the following architecture?


8 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    Do you mean multiple instances?

    An important point to note is that there should only be one instance consuming background jobs at any time.

  • User Avatar
    0
    ajayak created

    Yes @aaron. I want to run multiple instances.

    How can I control the background jobs so they only run in 1 server?

  • User Avatar
    0
    aaron created
    Support Team

    From https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers#disabling-job-execution:

    <blockquote>

    public class MyProjectWebModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.BackgroundJobs.IsJobExecutionEnabled = false;
        }
    
        //...
    }
    

    </blockquote>

  • User Avatar
    0
    ajayak created

    @aaron, is there any way to limit background jobs to just 1 instance? I do not want to disable background jobs

  • User Avatar
    1
    ismcagdas created
    Support Team

    Hi @ajayak

    You can get the value of Configuration.BackgroundJobs.IsJobExecutionEnabled from appsettings.json (or something similar) and set it to true only for one instance.

  • User Avatar
    0
    ajayak created

    Hi @ismcagdas, @aaron, I'm using Hangfire to manage background jobs.

    Should I also add a check on UseHangfireServer in Startup.cs?

  • User Avatar
    0
    ajayak created

    How can I control background jobs when I am running 2 instances of the application at same location?

    I'm using Azure. Under Scale out option, I can add multiple instances to my application. Source code will be same for these instances. Is it possible to control background job someway?

  • User Avatar
    0
    ismcagdas created
    Support Team

    @ajayak

    In that case, you can store a setting (or something similar) on the database and set it's value to true when the first app starts handling background job. Other apps can check the same setting value and ignore background job handling if the value is true.

    But in that way, you need to set this value to false when the app which starts background job handling shuts down.

    It requires a bit of extra custom work.