Open Closed

ABP deploy to kestrel server with Active directory integration. #6481


User avatar
0
Sraman created
  • ABP Framework version: v8.0.0
  • UI Type: MVC
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Wanted to deploy the app as a window service with kestrel server. But facing following error when starting the server,

And also wanted to implement Active directory integration with it. Any suggestions would be great.

Please find my program.cs code and let me know the required change if any,

using Pentapack.MRS.Data;
using Serilog;
using Serilog.Events;
using Volo.Abp.Data;

namespace Pentapack.MRS;

public class Program
{
    public static async Task<int> Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);
        builder.WebHost.ConfigureKestrel(serverOptions =>
        {
            serverOptions.ListenAnyIP(5000); // http
        });
        var loggerConfiguration = new LoggerConfiguration()
#if DEBUG
            .MinimumLevel.Debug()
#else
            .MinimumLevel.Warning()
#endif
            .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
            .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
            .Enrich.FromLogContext()
            .Enrich.WithProperty("Application", "Pentapack.MRS")
            .WriteTo.Async(c => c.File(builder.Configuration["App:LogFilePath"]))
            .WriteTo.Async(c => c.Console());

        if (IsMigrateDatabase(args))
        {
            loggerConfiguration.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning);
            loggerConfiguration.MinimumLevel.Override("Microsoft", LogEventLevel.Warning);
        }

        Log.Logger = loggerConfiguration.CreateLogger();

        try
        {
            builder.Host.AddAppSettingsSecretsJson()
                .UseAutofac()
                .UseSerilog();
            if (IsMigrateDatabase(args))
            {
                builder.Services.AddDataMigrationEnvironment();
            }
            builder.Services.AddWindowsService();
            await builder.AddApplicationAsync<MRSModule>();
            var app = builder.Build();
            await app.InitializeApplicationAsync();

            if (IsMigrateDatabase(args))
            {
                await app.Services.GetRequiredService<MRSDbMigrationService>().MigrateAsync();
                return 0;
            }

            Log.Information("Starting Pentapack.MRS.");
            await app.RunAsync();
            return 0;
        }
        catch (Exception ex)
        {
            if (ex is HostAbortedException)
            {
                throw;
            }

            Log.Fatal(ex, "Pentapack.MRS terminated unexpectedly!");
            return 1;
        }
        finally
        {
            Log.CloseAndFlush();
        }
    }

    private static bool IsMigrateDatabase(string[] args)
    {
        return args.Any(x => x.Contains("--migrate-database", StringComparison.OrdinalIgnoreCase));
    }
}

5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Wanted to deploy the app as a window service with kestrel server. But facing following error when starting the server,

    Are there any error logs on logs.txt and Win Event Viewer?

  • User Avatar
    0
    Sraman created

    hi

    Wanted to deploy the app as a window service with kestrel server. But facing following error when starting the server,

    Are there any error logs on logs.txt and Win Event Viewer?

    please find the logs as below

    2024-01-09 19:52:45.005 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.005 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.005 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.016 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.017 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.020 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.020 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.023 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.024 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.033 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.042 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.051 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.052 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.061 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.065 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.065 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.077 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.085 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.086 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.087 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.089 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.104 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.115 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.124 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.125 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.125 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.128 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.132 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.140 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.149 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.149 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.151 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.160 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.170 +05:30 [ERR] ABP-LIC-0021 - The path is empty. (Parameter 'path')
    2024-01-09 19:52:45.371 +05:30 [INF] User profile is available. Using 'C:\Users\Lsiva\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
    
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Do you have appsettings.secrets.json and AbpLicenseCode inside your app?

    Can your app run successfully without window service ?

  • User Avatar
    0
    Sraman created

    hi

    Do you have appsettings.secrets.json and AbpLicenseCode inside your app?

    Can your app run successfully without window service ?

    Yes. I do have appsettings.secrets.json with AbpLicenseCode. It is running fine on iis and docker without any issues.

  • User Avatar
    0
    alper created
    Support Team Director

    To diagnose the problem, there are 2 things to do:

    1. Run the Windows Service in administrator mode and try again

    2. To understand the correct paths, write a new simple console app and run this app as a Windows service. Log the following variables and send me the values. Can you see if the files are there in these paths? (If not, copy access-token.bin and AbpLicense.bin from your computer to the Server's related folders.)

    TokenPath:

    string TokenPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.UserProfile), ".abp", "cli", "access-token.bin");
    

    LicensePath:

    string LicensePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "AbpLicense.bin");
    
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11