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
        private void OnStarted()
        {
            _logger.LogInformation("Hosted service OnStarted");

            string pluginBasePath = ConfigurationCache.PluginPathPrefix.ToPhysicalPath();

            if (!System.IO.Directory.Exists(pluginBasePath))
            {
                System.IO.Directory.CreateDirectory(pluginBasePath);
            }

            //加载全局缓存
            ConfigurationCache.Reload();
            //初始化日志管理器
            Core.Log.LogManager.Init();
            //判断是否要自动根据配置文件注册节点信息
            if (AppCommandResolver.IsAutoRegister())
            {
                _logger.LogInformation("enabled auto register...");
                //设置节点信息
                ConfigurationCache.SetNode(_configuration);
                //初始化Quartz
                Common.QuartzManager.InitScheduler().Wait();
                //初始化延时队列容器
                DelayedTask.DelayPlanManager.Init();
            }
        }
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);
        }
Beispiel #4
0
        public ActionResult SaveConfig(IFormCollection form)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            foreach (string key in form.Keys)
            {
                items.Add(key, form[key]);
            }
            bool result = _systemService.SaveConfig(items, CurrentAdmin.UserName);

            if (result)
            {
                ConfigurationCache.Reload();
                return(SuccessTip("保存成功!"));
            }
            return(DangerTip("保存失败!"));
        }
Beispiel #5
0
        private void OnStarted()
        {
            _logger.LogInformation("Hosted service OnStarted");

            //加载全局缓存
            ConfigurationCache.Reload();
            //初始化日志管理器
            Core.Log.LogManager.Init();
            //判断是否要自动根据配置文件注册节点信息
            if (AppCommandResolver.IsAutoRegister())
            {
                _logger.LogInformation("enabled auto register...");
                //设置节点信息
                ConfigurationCache.SetNode(_configuration);
                //初始化Quartz
                Common.QuartzManager.InitScheduler().Wait();
            }
        }
Beispiel #6
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)
        {
            var s = Environment.MachineName;

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            //app.UseHttpsRedirection();

            app.UseDefaultFiles();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapHealthChecks("/health");
            });

            ConfigurationCache.RootServiceProvider = app.ApplicationServices;
            //加载全局缓存
            ConfigurationCache.SetNode(Configuration);
            ConfigurationCache.Reload();
            //初始化日志管理器
            Core.Log.LogManager.Init();
            //初始化Quartz
            Common.QuartzManager.InitScheduler().Wait();
            //启动系统任务
            Common.QuartzManager.Start <AppStart.TaskClearJob>("task-clear", "0 0/1 * * * ? *").Wait();

            appLifetime.ApplicationStopping.Register(OnStopping);
        }