sunpengfei
2025-08-07 a7287db2ada9ef606db5fe81cc8b66e2da44d345
FlexJobApi.Core/FlexJobApiCoreStartup.cs
@@ -1,4 +1,5 @@
using Furion;
using Consul;
using Furion;
using Furion.EventBus;
using MediatR;
using Microsoft.AspNetCore.Builder;
@@ -19,16 +20,16 @@
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddHealthChecks();
            services.AddConsoleFormatter(options =>
            {
                options.WithTraceId = true;
                options.WithStackFrame = true;
            });
            services.AddFileLogging(options =>
            {
                options.WithTraceId = true;
                options.WithStackFrame = true;
                options.FileNameRule = fileName =>
                {
                    return string.Format(fileName, DateTime.UtcNow);    // 如果是本地时间使用 DateTime.Now
@@ -38,10 +39,13 @@
            services.AddDatabaseLogging<DatabaseLoggingWriter>(options =>
            {
                options.WithTraceId = true;
                options.WithStackFrame = true;
            });
            services.AddConfigurableOptions<AliyunOptions>();
            services.AddHttpRemote();
            services.AddComponent<ConsulServiceComponent>();
            services.AddComponent<EventBusServiceComponent>();
@@ -50,11 +54,12 @@
            services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblies(App.Assemblies.ToArray()));
            services.AddHostedService<XmlDocBuildHostedService>();
            services.AddHostedService<BuildDynamicControllersHostedService>();
            services.AddJwt<JwtHandler>(enableGlobalAuthorize: true);
            services.AddCorsAccessor();
            services.AddHostedService<BuildDynamicControllersHostedService>();
            services.AddSpecificationDocuments(options =>
            {
@@ -70,6 +75,8 @@
                    .AddFriendlyException()
                    .AddDataValidation()
                    .AddInjectWithUnifyResult<FriendlyResultProvider>();
            services.AddMvcFilter<ResourceActionFilter>();
        }
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime lifetime)
@@ -106,8 +113,11 @@
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapHealthChecks("/healthz");
            });
            app.UseComponent<ConsulApplicationComponent>(env);
            //lifetime.ApplicationStarted.Register(async () =>
            //{
            //    await ResourceUtils.BuildDynamicControllersAsync();