Beispiel #1
0
        private void OnStarted()
        {
            _logger.LogInformation("Hosted service OnStarted");

            //读取节点配置信息
            ConfigurationCache.SetNode(_configuration);
            //注册节点
            AppStart.NodeRegistry.Register();
            //加载缓存
            ConfigurationCache.Reload();
            //初始化日志管理器
            Core.Log.LogManager.Init();

            //初始化系统任务
            FluentScheduler.JobManager.Initialize(new AppStart.SystemSchedulerRegistry());
            FluentScheduler.JobManager.JobException += info => Core.Log.LogHelper.Error("An error just happened with a FluentScheduler job", info.Exception);
            //任务恢复
            using (var scope = _serviceProvider.CreateScope())
            {
                Core.Services.ScheduleService service  = new Core.Services.ScheduleService();
                AutowiredServiceProvider      provider = new AutowiredServiceProvider();
                provider.PropertyActivate(service, scope.ServiceProvider);
                service.RunningRecovery();
            }
        }
Beispiel #2
0
 /// <summary>
 /// 执行计划
 /// </summary>
 public void Execute()
 {
     using (var scope = ConfigurationCache.RootServiceProvider.CreateScope())
     {
         Core.Services.ScheduleService service  = new Core.Services.ScheduleService();
         AutowiredServiceProvider      provider = new AutowiredServiceProvider();
         provider.PropertyActivate(service, scope.ServiceProvider);
         service.WorkerHealthCheck();
     }
 }
Beispiel #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime appLifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseCookiePolicy();
            //app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                //endpoints.MapControllers();
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Console}/{action=Index}/{id?}");
            });
            //加载全局缓存
            ConfigurationCache.RootServiceProvider = app.ApplicationServices;
            ConfigurationCache.SetNode(Configuration.GetSection("NodeSetting").Get <NodeSetting>());
            ConfigurationCache.Reload();
            //初始化日志管理器
            Core.Log.LogManager.Init();
            //注册节点
            AppStart.NodeRegistry.Register();
            //初始化系统任务
            FluentScheduler.JobManager.Initialize(new AppStart.SystemSchedulerRegistry());
            FluentScheduler.JobManager.JobException += info => Core.Log.LogHelper.Error("An error just happened with a FluentScheduler job", info.Exception);
            //任务恢复
            using (var scope = app.ApplicationServices.CreateScope())
            {
                Core.Services.ScheduleService service  = new Core.Services.ScheduleService();
                AutowiredServiceProvider      provider = new AutowiredServiceProvider();
                provider.PropertyActivate(service, scope.ServiceProvider);
                service.RunningRecovery();
            }
            appLifetime.ApplicationStopping.Register(OnStopping);
        }