/// <summary> /// 部署 /// </summary> /// <returns></returns> public override void Deploy(string stnm, string tcode, string ip) { bool flag = false; try { //服务是否存在 if (Helper_Service.Service_IsExisted(name)) { report.Add(comment + "升级..."); flag = Update();//升级 } else { report.Add(comment + "安装..."); flag = Install_DB(stnm, tcode, ip);//安装 } } catch (Exception e) { report.Error("部署" + comment + "异常", e); } finally { report.Add("部署-" + comment, flag ? "成功" : "失败"); } }
/// <summary> /// 关闭守护进程 /// </summary> /// <returns></returns> public static bool CloseDaemon() { if (Helper_Service.Service_IsExisted("TOEC_Daemon")) { if (Helper_Service.Server_Close("TOEC_Daemon")) { report.Add("守护进程已经停止"); return(true); } else { report.Error("守护进程关闭异常"); return(false); } } else { report.Add("未安装守护进程"); return(true); } }
/// <summary> /// 部署 /// </summary> /// <param name="stnm"></param> /// <param name="tcode"></param> /// <param name="ip"></param> public override void Deploy(string stnm, string tcode, string ip) { bool flag = false; try { //特殊处理:清理老版不规范的服务 Delete_Old_Software(); //判断服务是否存在 if (Helper_Service.Service_IsExisted(name)) { #region 升级 report.Add(comment + "升级..."); if (!Helper_Service.Server_Close(name)) //先关闭服务 { report.Error(name + "服务关闭失败"); } else { Thread.Sleep(5000); report.Add(name + "服务已关闭"); report.Add("检查残留进程..."); if (Helper_Process.CheckProcessExists(name)) { if (Helper_Process.KillProcess(name)) { report.Add("进程已经被强制结束"); } else { report.Error("进程强制结束失败"); } } flag = Update(stnm, tcode, ip); } #endregion } else { //安装 report.Add(comment + "安装..."); flag = Install(stnm, tcode, ip);//安装 } //部署后自动开启 if (AutoStart) { DirectoryInfo dir = GetDir_FromDeploy(name); if (dir != null) { FileInfo fi_start = new FileInfo(dir.FullName + "\\Start.bat"); if (File.Exists(fi_start.FullName)) { Process.Start(fi_start.FullName); report.Add(name + "已开启"); } else { report.Add(fi_start.FullName + "未找到"); } } } } catch (Exception e) { report.Error("部署" + comment + "异常", e); } finally { report.Add("部署-" + comment, flag ? "成功" : "失败"); } }