Starts in:
1 DAY
21 HRS
59 MIN
0 SEC
Starts in:
1 D
21 H
59 M
0 S
Open Closed

Same redis configuration not working on two environment same time Staging and Production #4818


User avatar
0
isteer created

Hello Team,

OUR ABP CONFIGURATION:

ABP Framework version: v7.0.0 UI type: MVC DB provider: EF Core Tiered (MVC) or Identity Server Separated (Angular): Tiered MVC Exception message and stack trace

We have deployed application on staging and production both environment, following are the URLS:

Staging http://web.stage.careermaps.co.uk/

Production https://g2c.careermaps.co.uk/

Both are using redis configuration: redis.mindmill.co.uk defined in appsettings.json for redis configuration

In GTCManagementWebModule,GTCManagementHostModule and GTCManagementAuthModule,

We have defined different names for application name like : GemsStaging, GemsProduction (below attached screenshot for the same)

But after deploying both the staging and production sites, only one of them works at a time. (Attached error screenshot), if we stop staging the website then the production site will work and if we stop the production site then staging will work.

Any idea how we can use common redis server configuration for both environment staging and production


16 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Can you share the error logs?

  • User Avatar
    0
    isteer created

    Sure, which site logs should I send, staging one or production one?

  • User Avatar
    0
    isteer created

    Also share the email where I need to send logs

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Both of them, thanks. shiwei.liang@volosoft.com

  • User Avatar
    0
    isteer created

    Hello Team,

    Shared logs above over email, please confirm if you received logs, shared links of all URLs for staging and production.

  • User Avatar
    0
    isteer created

    Hello Team,

    Any updates

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can consider configure the InstanceName

    Configure<RedisCacheOptions>(options =>
    {
        var instanceName = string.Empty;
        if (hostingEnvironment.IsProduction())
        {
            instanceName = "Production";
        }
    
        if (hostingEnvironment.IsStaging())
        {
            instanceName = "Staging";
        }
    
        options.InstanceName = instanceName;
    });
    
  • User Avatar
    0
    isteer created

    Hello,

    Which place need to add this code. As can not see this RedisCacheOptions declared or used any of the module pages (Authservermodule, WebModule)

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    You need to configure every project that uses Redis (AuthServer,Web, HttpApi.Host)

  • User Avatar
    0
    isteer created

    Hello

    This needs to be added before we setup applicationname and connection with redis right? Check screenshot and code and confirm please.

     private void ConfigureDataProtection(
            ServiceConfigurationContext context,
            IConfiguration configuration,
            IWebHostEnvironment hostingEnvironment)
        {
            Configure<RedisCacheOptions>(options =>
            {
                options.InstanceName = "Production";
            });
            var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("GemsProduction");
            if (!hostingEnvironment.IsDevelopment())
            {
                var redis = ConnectionMultiplexer
                  .Connect(configuration["Redis:Configuration"]);
                dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "GemsProduction-Protection-Keys");
            }
        }
    
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi

    Yes, it is.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Or you can specify a different database number to isolate the staging and production environment

    appsettings.staging.json

    "Redis": {
       "Configuration": "redis.mindmill.co.uk,defaultDatabase=1"
     }
    

    appsettings.production.json

    "Redis": {
       "Configuration": "redis.mindmill.co.uk,defaultDatabase=2"
     }
    
  • User Avatar
    0
    isteer created

    Thanks, Just need to add in appsettings part, no need to change in configuration side of code, right?

     Configure<RedisCacheOptions>(options =>
            {
                options.InstanceName = "Production";
            });
            var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("GemsProduction");
            if (!hostingEnvironment.IsDevelopment())
            {
                var redis = ConnectionMultiplexer
                  .Connect(configuration["Redis:Configuration"]);
                dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "GemsProduction-Protection-Keys");
            }
    
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Yes

  • User Avatar
    0
    isteer created

    Thanks, Let me try and redeploy this and will update you on the impact. Meanwhile can you check the other ticket also where I have posted reply.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    ok

    Meanwhile can you check the other ticket also where I have posted reply.

    Where?

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06