|
@@ -8,12 +8,13 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.constant.WebsocketConst;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
-import org.jeecg.common.util.UUIDGenerator;
|
|
|
import org.jeecg.modules.adweb.common.dto.ServerDTO;
|
|
|
import org.jeecg.modules.adweb.common.service.FeishuService;
|
|
|
import org.jeecg.modules.adweb.common.service.ShellService;
|
|
|
import org.jeecg.modules.adweb.common.service.WebSocketService;
|
|
|
import org.jeecg.modules.adweb.common.util.ShellSSH2Util;
|
|
|
+import org.jeecg.modules.adweb.server.entity.AdwebServer;
|
|
|
+import org.jeecg.modules.adweb.server.service.IAdwebServerService;
|
|
|
import org.jeecg.modules.adweb.site.constant.WordPressConstants;
|
|
|
import org.jeecg.modules.adweb.site.entity.AdwebSite;
|
|
|
import org.jeecg.modules.adweb.system.entity.SysException;
|
|
@@ -51,12 +52,8 @@ public class SelfWebSiteService {
|
|
|
@Resource
|
|
|
private WebSocketService webSocketService;
|
|
|
|
|
|
-
|
|
|
- @Value(value = "${jeecg.minio.dataPrefix}")
|
|
|
- private String dataPrefix;
|
|
|
-
|
|
|
- @Value(value = "${jeecg.minio_us.dataPrefix}")
|
|
|
- private String usDataPrefix;
|
|
|
+ @Resource
|
|
|
+ private IAdwebServerService serverService;
|
|
|
|
|
|
@Value("${AdwebSiteConnect.host}")
|
|
|
private String host;
|
|
@@ -75,13 +72,17 @@ public class SelfWebSiteService {
|
|
|
|
|
|
private String errorMsg = "";
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * @param tempId 模板ID
|
|
|
- * @param uid 系统用户信息
|
|
|
- * @param name 站点名称
|
|
|
- * @param planId 新建站点绑定的套餐
|
|
|
- * @return
|
|
|
+ * 创建站点的方法
|
|
|
+ *
|
|
|
+ * @param user 当前登录用户
|
|
|
+ * @param tempId 模板ID
|
|
|
+ * @param uid 用户ID
|
|
|
+ * @param name 站点名称
|
|
|
+ * @param planId 套餐ID
|
|
|
+ * @param sysUser 系统用户
|
|
|
+ * @param giveDay 赠送天数
|
|
|
+ * @param compensateDay 补偿天数
|
|
|
*/
|
|
|
@Async
|
|
|
public void createSite(LoginUser user, Long tempId, String uid, String name, String planId, LoginUser sysUser, Integer giveDay, Integer compensateDay) {
|
|
@@ -139,6 +140,15 @@ public class SelfWebSiteService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除指定的广告网站
|
|
|
+ * <p>
|
|
|
+ * 此方法通过执行远程服务器上的Shell脚本来删除广告网站资源,并在删除成功后通知用户
|
|
|
+ * 如果删除失败,会记录错误信息并抛出异常
|
|
|
+ *
|
|
|
+ * @param user 当前操作的用户,用于发送通知
|
|
|
+ * @param adwebSite 要删除的广告网站对象,包含网站代码和域名等信息
|
|
|
+ */
|
|
|
@Async
|
|
|
public void removeSite(LoginUser user, AdwebSite adwebSite) {
|
|
|
try {
|
|
@@ -179,6 +189,13 @@ public class SelfWebSiteService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 当执行Shell命令失败时调用此方法记录错误信息
|
|
|
+ *
|
|
|
+ * @param cmd 执行的Shell命令,用于标识操作
|
|
|
+ * @param adwebSite 发生错误的广告网站实例,包含站点信息
|
|
|
+ * @param errorMsg 错误信息描述,详细说明执行失败的原因
|
|
|
+ */
|
|
|
private void exceShellFailed(String cmd, AdwebSite adwebSite, String errorMsg) {
|
|
|
SysException sysException = new SysException();
|
|
|
|
|
@@ -190,6 +207,13 @@ public class SelfWebSiteService {
|
|
|
sysExceptionService.save(sysException);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 处理临时站点创建失败的逻辑
|
|
|
+ * 当临时站点创建失败时,此方法会被调用,更新站点状态并记录错误信息
|
|
|
+ *
|
|
|
+ * @param adwebSite 代表临时站点的对象,包含站点的相关信息
|
|
|
+ * @param errorMsg 描述创建失败的错误信息
|
|
|
+ */
|
|
|
private void createSiteFailed(AdwebSite adwebSite, String errorMsg) {
|
|
|
adwebSite.setStatus(4); // 临时站点创建失败
|
|
|
siteService.updateById(adwebSite);
|
|
@@ -205,222 +229,26 @@ public class SelfWebSiteService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void msgSetInSession(HttpServletRequest request, String line) {
|
|
|
- HttpSession session = request.getSession();
|
|
|
- if ("CP_TAR_GZ_START".equals(line)) {
|
|
|
- session.setAttribute("testSiteProcess", "CP_TAR_GZ");
|
|
|
- }
|
|
|
- if ("SQL_DUMP_IMPORT_START".equals(line)) {
|
|
|
- session.setAttribute("testSiteProcess", "SQL_DUMP_IMPORT");
|
|
|
- }
|
|
|
- if ("WP_UDONM_START".equals(line)) {
|
|
|
- session.setAttribute("testSiteProcess", "WP_UDONM");
|
|
|
- }
|
|
|
- if ("WP_UDONM_END".equals(line)) {
|
|
|
- session.setAttribute("testSiteProcess", "SUCCESS");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void msgSetInSessionProd(HttpServletRequest request, String line) {
|
|
|
- HttpSession session = request.getSession();
|
|
|
- if ("wget_tar_start".equals(line)) {
|
|
|
- session.setAttribute("prodSiteProcess", "wget_tar_start");
|
|
|
- }
|
|
|
- if ("wget_sql_start".equals(line)) {
|
|
|
- session.setAttribute("prodSiteProcess", "wget_sql_start");
|
|
|
- }
|
|
|
- if ("start tar zxf".equals(line)) {
|
|
|
- session.setAttribute("prodSiteProcess", "start tar zxf");
|
|
|
- }
|
|
|
- if ("wp_udomain_start".equals(line)) {
|
|
|
- session.setAttribute("prodSiteProcess", "wp_udomain_start");
|
|
|
- }
|
|
|
- if ("wp_udomain_end".equals(line)) {
|
|
|
- session.setAttribute("prodSiteProcess", "success");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 站点启动/停止
|
|
|
- *
|
|
|
- * @param sysUser
|
|
|
- * @param siteId
|
|
|
- * @param status
|
|
|
- * @return
|
|
|
- */
|
|
|
- public boolean siteStartOrStop(LoginUser sysUser, Integer siteId, Integer status) {
|
|
|
- AdwebSite adwebSite = siteService.getById(siteId);
|
|
|
-
|
|
|
- // 获取站点所在生产服务器信息
|
|
|
- ServerDTO serverInfo = new ServerDTO();
|
|
|
- boolean flag = false;
|
|
|
- switch (status) {
|
|
|
- case 1:
|
|
|
- flag = startSiteLocal(sysUser, adwebSite);
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- flag = stopSiteLocal(sysUser, adwebSite);
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- flag = startSite(sysUser, adwebSite, serverInfo);
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- flag = stopSite(sysUser, adwebSite, serverInfo);
|
|
|
- break;
|
|
|
- }
|
|
|
- return flag;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
- * 站点启动脚本调用(未发布)
|
|
|
+ * 发布站点到生产环境
|
|
|
*
|
|
|
- * @param sysUser
|
|
|
- * @param adwebSite
|
|
|
- * @return
|
|
|
+ * @param request HTTP请求对象,用于获取会话信息
|
|
|
+ * @param serverId 服务器ID,未在方法体内使用
|
|
|
+ * @param domain 域名,用于站点发布
|
|
|
+ * @param siteCode 站点代码,标识特定的站点
|
|
|
*/
|
|
|
- private boolean startSiteLocal(LoginUser sysUser, AdwebSite adwebSite) {
|
|
|
- //站点启动
|
|
|
- String cmd = "/home/ci-user/shell/start_site " + adwebSite.getCode() + " ";
|
|
|
- shellService.exceShellByPwd(cmd, host, port, username, password, new ShellSSH2Util.StdoutListener() {
|
|
|
- @Override
|
|
|
- public void stdout(String line) {
|
|
|
- log.info("标准 :" + line);
|
|
|
- if ("ERROR:FILE_NAME IS EXISTS".equals(line)) {
|
|
|
- // TODO ----
|
|
|
- log.error("恢复测试站点异常:" + line);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void stderr(String line) {
|
|
|
- log.info("错误 :" + line);
|
|
|
- }
|
|
|
- });
|
|
|
- return siteStatusUpdate(sysUser, adwebSite, 0);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 站点停止脚本调用(未发布)
|
|
|
- *
|
|
|
- * @param sysUser
|
|
|
- * @param adwebSite
|
|
|
- * @return
|
|
|
- */
|
|
|
- private boolean stopSiteLocal(LoginUser sysUser, AdwebSite adwebSite) {
|
|
|
- String cmd = "/home/ci-user/shell/stop_site " + adwebSite.getCode() + " ";
|
|
|
- shellService.exceShellByPwd(cmd, host, port, username, password, new ShellSSH2Util.StdoutListener() {
|
|
|
- @Override
|
|
|
- public void stdout(String line) {
|
|
|
- log.info("标准 :" + line);
|
|
|
- if ("ERROR:FILE_NAME IS EXISTS".equals(line)) {
|
|
|
- // TODO ----
|
|
|
- log.error("停止测试站点异常:" + line);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void stderr(String line) {
|
|
|
- log.info("错误 :" + line);
|
|
|
- }
|
|
|
- });
|
|
|
- return siteStatusUpdate(sysUser, adwebSite, 3);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 站点启动脚本调用(生产环境)
|
|
|
- *
|
|
|
- * @param sysUser
|
|
|
- * @param adwebSite
|
|
|
- * @return
|
|
|
- */
|
|
|
- private boolean startSite(LoginUser sysUser, AdwebSite adwebSite, ServerDTO serverInfo) {
|
|
|
- //站点启动
|
|
|
- String cmd = "./shell/start_site " + serverInfo.getIp() + " " + adwebSite.getCode() + " ";
|
|
|
- shellService.exceShell(cmd, new ShellSSH2Util.StdoutListener() {
|
|
|
- @Override
|
|
|
- public void stdout(String line) {
|
|
|
- log.info("MJJ控制台 :" + line);
|
|
|
- if ("ERROR:FILE_NAME IS EXISTS".equals(line)) {
|
|
|
- // TODO ----
|
|
|
- log.error("恢复站点异常:" + line);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void stderr(String line) {
|
|
|
- log.info("错误 :" + line);
|
|
|
- }
|
|
|
- }, serverInfo);
|
|
|
- return siteStatusUpdate(sysUser, adwebSite, 0);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 站点停止脚本调用(生产环境)
|
|
|
- *
|
|
|
- * @param sysUser
|
|
|
- * @param adwebSite
|
|
|
- * @return
|
|
|
- */
|
|
|
- private boolean stopSite(LoginUser sysUser, AdwebSite adwebSite, ServerDTO serverInfo) {
|
|
|
- String cmd = "./shell/stop_site " + serverInfo.getIp() + " " + adwebSite.getCode() + " ";
|
|
|
- shellService.exceShell(cmd, new ShellSSH2Util.StdoutListener() {
|
|
|
- @Override
|
|
|
- public void stdout(String line) {
|
|
|
- log.info("MJJ控制台 :" + line);
|
|
|
- if ("ERROR:FILE_NAME IS EXISTS".equals(line)) {
|
|
|
- // TODO ----
|
|
|
- log.error("停止站点异常:" + line);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void stderr(String line) {
|
|
|
- log.info("错误 :" + line);
|
|
|
- }
|
|
|
- }, serverInfo);
|
|
|
- return siteStatusUpdate(sysUser, adwebSite, 3);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 站点状态更改
|
|
|
- *
|
|
|
- * @param sysUser
|
|
|
- * @param adwebSite
|
|
|
- * @param runStatus
|
|
|
- * @return
|
|
|
- */
|
|
|
- private boolean siteStatusUpdate(LoginUser sysUser, AdwebSite adwebSite, Integer runStatus) {
|
|
|
- if (runStatus.equals(3)) {
|
|
|
- adwebSite.setStopTime(new Date());
|
|
|
- adwebSite.setStopUid(sysUser.getId());
|
|
|
- }
|
|
|
- adwebSite.setRunStatus(runStatus);
|
|
|
- return siteService.updateById(adwebSite);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 发布站点(生产环境)
|
|
|
- *
|
|
|
- * @param domain 新域名
|
|
|
- * @param siteId 站点ID
|
|
|
- */
|
|
|
- public Result<?> releaseSite(HttpServletRequest request, String domain, Integer siteId) {
|
|
|
- log.info("===== releaseSite domain:{},siteId:{} ====", domain, siteId);
|
|
|
+ @Async
|
|
|
+ public void releaseSite(HttpServletRequest request, String serverId, String domain, String siteCode) {
|
|
|
+ log.info("===== releaseSite domain:{},siteCode:{} ====", domain, siteCode);
|
|
|
StringBuilder statusSuccess = new StringBuilder();
|
|
|
StringBuilder statusFail = new StringBuilder();
|
|
|
- AdwebSite adwebSite = siteService.getById(siteId);
|
|
|
- String siteToken = UUIDGenerator.generate().toUpperCase();
|
|
|
+ AdwebSite adwebSite = siteService.getSiteByCode(siteCode);
|
|
|
HttpSession session = request.getSession();
|
|
|
-// String cmd = " ./shell/auto_website " + serverInfo.getIp() + " " + adwebSite.getCode() + " " + adwebSite.getInCode() + " " + domain + " " + siteToken + " " + tempDomain;
|
|
|
- if (StringUtils.isEmpty(adwebSite.getDevServerIp())) {
|
|
|
- return Result.error("该站点的服务器IP没有设置,请设置后在发布上线!");
|
|
|
- }
|
|
|
- log.info("===== releaseSite domain:{},siteId:{},getDevServerIp:{} ====", domain, siteId, adwebSite.getDevServerIp());
|
|
|
- if ((!WordPressConstants.DEV_CI1.equals(adwebSite.getDevServerIp())) && (!WordPressConstants.DEV_CI2.equals(adwebSite.getDevServerIp()))) {
|
|
|
- return Result.error("该站点的服务器IP设置不正确,请重试!");
|
|
|
+ AdwebServer adwebServer = serverService.getById(serverId);
|
|
|
+
|
|
|
+ if (adwebServer == null) {
|
|
|
+ log.error("发布生产环境时未指定服务器");
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
String usWest118ServerShellPath = "/home/ci-user/shell";
|
|
@@ -432,7 +260,7 @@ public class SelfWebSiteService {
|
|
|
domain = domain.replace("www.", "");
|
|
|
}
|
|
|
String dbName = domain.replaceAll("[^a-zA-Z0-9]", "") + "_" + adwebSite.getCode();
|
|
|
- log.info("===== releaseSite domain:{},siteId:{},originDomain:{},domain:{},dbName:{} ====", domain, siteId, originDomain, domain, dbName);
|
|
|
+ log.info("===== releaseSite domain:{},siteCode:{},originDomain:{},domain:{},dbName:{} ====", domain, siteCode, originDomain, domain, dbName);
|
|
|
|
|
|
String cmd = "";
|
|
|
if (WordPressConstants.DEV_CI1.equals(adwebSite.getDevServerIp())) {
|
|
@@ -441,17 +269,18 @@ public class SelfWebSiteService {
|
|
|
if (WordPressConstants.DEV_CI2.equals(adwebSite.getDevServerIp())) {
|
|
|
cmd = "sudo sh " + usWest118ServerShellPath + "/adweb-publish-devci2_http.sh " + adwebSite.getCode() + " " + domain + " " + dbName;
|
|
|
}
|
|
|
- log.info("===== releaseSite originDomain:{},domain:{},siteId:{},cmd:{} ====", originDomain, domain, siteId, cmd);
|
|
|
+ log.info("===== releaseSite originDomain:{},domain:{},siteCode:{},cmd:{} ====", originDomain, domain, siteCode, cmd);
|
|
|
|
|
|
if (StringUtils.isEmpty(cmd)) {
|
|
|
String errorMsg = "网站上线脚本命令获取失败!";
|
|
|
String title = "网站域名:" + originDomain + " 站点发布失败";
|
|
|
- String message = "**站点ID:** " + siteId + "\n";
|
|
|
+ String message = "**站点ID:** " + siteCode + "\n";
|
|
|
message += "**临时域名:** " + adwebSite.getDomainDev() + "\n";
|
|
|
message += "**服务器IP:** " + adwebSite.getDevServerIp() + "\n";
|
|
|
message += "**错误原因:** " + errorMsg + "\n";
|
|
|
sendAdWebV2FeiShuMsg(title, message);
|
|
|
- return Result.error("该站点的发布上线命令执行失败,请重试!");
|
|
|
+ Result.error("该站点的发布上线命令执行失败,请重试!");
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
// return false;
|
|
@@ -503,11 +332,11 @@ public class SelfWebSiteService {
|
|
|
// }
|
|
|
//正式域名
|
|
|
|
|
|
- log.info("===== releaseSite originDomain:{},domain:{},siteId:{},statusSuccess:{} ====", originDomain, domain, siteId, statusSuccess);
|
|
|
- log.info("===== releaseSite originDomain:{},domain:{},siteId:{},statusFail:{} ====", originDomain, domain, siteId, statusFail);
|
|
|
+ log.info("===== releaseSite originDomain:{},domain:{},siteId:{},statusSuccess:{} ====", originDomain, domain, siteCode, statusSuccess);
|
|
|
+ log.info("===== releaseSite originDomain:{},domain:{},siteId:{},statusFail:{} ====", originDomain, domain, siteCode, statusFail);
|
|
|
if (StringUtils.isNotEmpty(statusFail.toString())) {
|
|
|
String title = "网站域名:" + originDomain + " 站点发布失败";
|
|
|
- String message = "**站点ID:** " + siteId + "\n";
|
|
|
+ String message = "**站点ID:** " + siteCode + "\n";
|
|
|
message += "**临时域名:** " + adwebSite.getDomainDev() + "\n";
|
|
|
message += "**服务器IP:** " + adwebSite.getDevServerIp() + "\n";
|
|
|
message += "**错误信息:** " + statusFail.toString() + "\n";
|
|
@@ -516,10 +345,10 @@ public class SelfWebSiteService {
|
|
|
// 站点发布失败
|
|
|
adwebSite.setStatus(6);
|
|
|
siteService.updateById(adwebSite);
|
|
|
- return Result.error("网站发布上线失败!");
|
|
|
+ Result.error("网站发布上线失败!");
|
|
|
} else {
|
|
|
String title = "网站域名:" + originDomain + " 站点发布成功";
|
|
|
- String message = "**站点ID:** " + siteId + "\n";
|
|
|
+ String message = "**站点ID:** " + siteCode + "\n";
|
|
|
message += "**临时域名:** " + adwebSite.getDomainDev() + "\n";
|
|
|
message += "**服务器IP:** " + adwebSite.getDevServerIp() + "\n";
|
|
|
sendAdWebV2FeiShuMsg(title, message);
|
|
@@ -540,14 +369,14 @@ public class SelfWebSiteService {
|
|
|
// updateWrapper.set("domain", domain);
|
|
|
// seoKeywordsService.update(updateWrapper);
|
|
|
session.setAttribute("shellLineModular", "");
|
|
|
- return Result.OK("网站发布上线成功!");
|
|
|
+ Result.OK("网站发布上线成功!");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error("站点发布失败,退出执行;" + e.getMessage(), e);
|
|
|
// 站点发布失败
|
|
|
adwebSite.setStatus(6);
|
|
|
siteService.updateById(adwebSite);
|
|
|
- return Result.error("网站发布上线失败!");
|
|
|
+ Result.error("网站发布上线失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -629,6 +458,166 @@ public class SelfWebSiteService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 站点启动/停止
|
|
|
+ *
|
|
|
+ * @param sysUser
|
|
|
+ * @param siteId
|
|
|
+ * @param status
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean siteStartOrStop(LoginUser sysUser, Integer siteId, Integer status) {
|
|
|
+ AdwebSite adwebSite = siteService.getById(siteId);
|
|
|
+
|
|
|
+ // 获取站点所在生产服务器信息
|
|
|
+ ServerDTO serverInfo = new ServerDTO();
|
|
|
+ boolean flag = false;
|
|
|
+ switch (status) {
|
|
|
+ case 1:
|
|
|
+ flag = startSiteLocal(sysUser, adwebSite);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ flag = stopSiteLocal(sysUser, adwebSite);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ flag = startSite(sysUser, adwebSite, serverInfo);
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ flag = stopSite(sysUser, adwebSite, serverInfo);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 站点启动脚本调用(未发布)
|
|
|
+ *
|
|
|
+ * @param sysUser
|
|
|
+ * @param adwebSite
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean startSiteLocal(LoginUser sysUser, AdwebSite adwebSite) {
|
|
|
+ //站点启动
|
|
|
+ String cmd = "/home/ci-user/shell/start_site " + adwebSite.getCode() + " ";
|
|
|
+ shellService.exceShellByPwd(cmd, host, port, username, password, new ShellSSH2Util.StdoutListener() {
|
|
|
+ @Override
|
|
|
+ public void stdout(String line) {
|
|
|
+ log.info("标准 :" + line);
|
|
|
+ if ("ERROR:FILE_NAME IS EXISTS".equals(line)) {
|
|
|
+ // TODO ----
|
|
|
+ log.error("恢复测试站点异常:" + line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void stderr(String line) {
|
|
|
+ log.info("错误 :" + line);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return siteStatusUpdate(sysUser, adwebSite, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 站点停止脚本调用(未发布)
|
|
|
+ *
|
|
|
+ * @param sysUser
|
|
|
+ * @param adwebSite
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean stopSiteLocal(LoginUser sysUser, AdwebSite adwebSite) {
|
|
|
+ String cmd = "/home/ci-user/shell/stop_site " + adwebSite.getCode() + " ";
|
|
|
+ shellService.exceShellByPwd(cmd, host, port, username, password, new ShellSSH2Util.StdoutListener() {
|
|
|
+ @Override
|
|
|
+ public void stdout(String line) {
|
|
|
+ log.info("标准 :" + line);
|
|
|
+ if ("ERROR:FILE_NAME IS EXISTS".equals(line)) {
|
|
|
+ // TODO ----
|
|
|
+ log.error("停止测试站点异常:" + line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void stderr(String line) {
|
|
|
+ log.info("错误 :" + line);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return siteStatusUpdate(sysUser, adwebSite, 3);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 站点启动脚本调用(生产环境)
|
|
|
+ *
|
|
|
+ * @param sysUser
|
|
|
+ * @param adwebSite
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean startSite(LoginUser sysUser, AdwebSite adwebSite, ServerDTO serverInfo) {
|
|
|
+ //站点启动
|
|
|
+ String cmd = "./shell/start_site " + serverInfo.getIp() + " " + adwebSite.getCode() + " ";
|
|
|
+ shellService.exceShell(cmd, new ShellSSH2Util.StdoutListener() {
|
|
|
+ @Override
|
|
|
+ public void stdout(String line) {
|
|
|
+ log.info("MJJ控制台 :" + line);
|
|
|
+ if ("ERROR:FILE_NAME IS EXISTS".equals(line)) {
|
|
|
+ // TODO ----
|
|
|
+ log.error("恢复站点异常:" + line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void stderr(String line) {
|
|
|
+ log.info("错误 :" + line);
|
|
|
+ }
|
|
|
+ }, serverInfo);
|
|
|
+ return siteStatusUpdate(sysUser, adwebSite, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 站点停止脚本调用(生产环境)
|
|
|
+ *
|
|
|
+ * @param sysUser
|
|
|
+ * @param adwebSite
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean stopSite(LoginUser sysUser, AdwebSite adwebSite, ServerDTO serverInfo) {
|
|
|
+ String cmd = "./shell/stop_site " + serverInfo.getIp() + " " + adwebSite.getCode() + " ";
|
|
|
+ shellService.exceShell(cmd, new ShellSSH2Util.StdoutListener() {
|
|
|
+ @Override
|
|
|
+ public void stdout(String line) {
|
|
|
+ log.info("MJJ控制台 :" + line);
|
|
|
+ if ("ERROR:FILE_NAME IS EXISTS".equals(line)) {
|
|
|
+ // TODO ----
|
|
|
+ log.error("停止站点异常:" + line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void stderr(String line) {
|
|
|
+ log.info("错误 :" + line);
|
|
|
+ }
|
|
|
+ }, serverInfo);
|
|
|
+ return siteStatusUpdate(sysUser, adwebSite, 3);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 站点状态更改
|
|
|
+ *
|
|
|
+ * @param sysUser
|
|
|
+ * @param adwebSite
|
|
|
+ * @param runStatus
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean siteStatusUpdate(LoginUser sysUser, AdwebSite adwebSite, Integer runStatus) {
|
|
|
+ if (runStatus.equals(3)) {
|
|
|
+ adwebSite.setStopTime(new Date());
|
|
|
+ adwebSite.setStopUid(sysUser.getId());
|
|
|
+ }
|
|
|
+ adwebSite.setRunStatus(runStatus);
|
|
|
+ return siteService.updateById(adwebSite);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param msgTitle
|
|
|
* @param message
|