protected override void OnStart(string[] args) { DebuggableAttribute att = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttribute <DebuggableAttribute>(); if (att.IsJITTrackingEnabled) { //Debug模式才让线程停止10s,方便附加到进程调试 Thread.Sleep(10000); } //配置信息读取 ConfigInit.InitConfig(); //3.系统参数配置初始化 MefConfig.Init(); ConfigManager configManager = MefConfig.TryResolve <ConfigManager>(); configManager.Init(); QuartzHelper.InitScheduler(); QuartzHelper.StartScheduler(); // 保持web服务运行 ThreadPool.QueueUserWorkItem((o) => { //启动站点 Startup.Start(SystemConfig.WebPort); }); }
protected override void OnStart(string[] args) { try { //1.MEF初始化 MefConfig.Init(); //2.数据库初始化连接 ConfigInit.InitConfig(); //3.系统参数配置初始化 ConfigManager configManager = MefConfig.TryResolve <ConfigManager>(); configManager.Init(); //4.任务启动 QuartzHelper.InitScheduler(); QuartzHelper.StartScheduler(); //5.加载SQL信息到缓存中 XmlCommandManager.LoadCommnads(SysConfig.XmlCommandFolder); //开发时监听资源文件变化,用于实时更新 DevelperHelper.WatcherResourceChange(); // 保持web服务运行 ThreadPool.QueueUserWorkItem((o) => { //7.启动站点 using (NancyHost host = Startup.Start(SystemConfig.WebPort)) { //调用系统默认的浏览器 string url = string.Format("http://127.0.0.1:{0}", SystemConfig.WebPort); LogHelper.WriteLog(string.Format("系统已启动,当前监听站点地址:{0}", url)); try { //4.消息队列启动 RabbitMQClient.InitClient(); } catch (Exception ex) { Console.WriteLine(ex); } //8.系统命令初始化 CommandHelp.Init(); } }); } catch (Exception ex) { LogHelper.WriteLog("服务启动异常", ex); } }