|
@@ -118,7 +118,7 @@ public class SelfWebSiteService {
|
|
|
String[] userIds = {user.getId()};
|
|
|
// 给该站点所属的用户发送消息
|
|
|
log.info("发送创建站点通知");
|
|
|
- webSocketService.sendMessage(userIds, "您的站点已经创建成功,请在站点管理中查看该站点详细信息", WebsocketConst.CMD_CREATE_SITE);
|
|
|
+ webSocketService.sendMessage(userIds, "站点创建完成通知", "您的站点已经创建成功,请在站点管理中查看该站点详细信息", WebsocketConst.CMD_MANAGE_SITE);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -139,11 +139,12 @@ public class SelfWebSiteService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void removeSite(AdwebSite adwebSite) {
|
|
|
+ @Async
|
|
|
+ public void removeSite(LoginUser user, AdwebSite adwebSite) {
|
|
|
try {
|
|
|
|
|
|
// 执行临时服务器shell脚本,生成临时站点
|
|
|
- String cmd = "sh /opt/adweb3/shell/remove-and-bak-wpsite " + adwebSite.getCode();
|
|
|
+ String cmd = "sh /opt/adweb3/shell/remove-and-bak-wpsite.sh " + adwebSite.getCode();
|
|
|
|
|
|
AdwebSite finalAdwebSite = adwebSite;
|
|
|
shellService.createShareSiteByPwd(cmd, host, port, username, password, new ShellSSH2Util.StdoutListener() {
|
|
@@ -152,19 +153,12 @@ public class SelfWebSiteService {
|
|
|
log.info("标准 :{}", line);
|
|
|
|
|
|
if (line.startsWith("执行命令成功")) {
|
|
|
- log.info("站点创建成功!更新站点状态");
|
|
|
-
|
|
|
- // 更新站点流程状态
|
|
|
- siteService.updateSiteFlow(finalAdwebSite.getCode());
|
|
|
-
|
|
|
- // 临时站点创建成功
|
|
|
- finalAdwebSite.setStatus(2);
|
|
|
- siteService.updateById(finalAdwebSite);
|
|
|
+ log.info("站点资源删除成功!");
|
|
|
|
|
|
-// String[] userIds = {user.getId()};
|
|
|
-// // 给该站点所属的用户发送消息
|
|
|
-// log.info("发送创建站点通知");
|
|
|
-// webSocketService.sendMessage(userIds, "您的站点已经创建成功,请在站点管理中查看该站点详细信息", WebsocketConst.CMD_CREATE_SITE);
|
|
|
+ String[] userIds = {user.getId()};
|
|
|
+ // 给该站点所属的用户发送消息
|
|
|
+ log.info("发送删除站点资源通知");
|
|
|
+ webSocketService.sendMessage(userIds, "站点删除通知", "站点资源" + finalAdwebSite.getDomain() + "已经从系统删除!", WebsocketConst.CMD_MANAGE_SITE);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -177,14 +171,25 @@ public class SelfWebSiteService {
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(errorMsg)) {
|
|
|
- createSiteFailed(adwebSite, errorMsg);
|
|
|
+ exceShellFailed("删除站点资源", adwebSite, errorMsg);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.error("在wp服务器上生成站点文件失败");
|
|
|
- createSiteFailed(adwebSite, e.getMessage());
|
|
|
+ log.error("在wp服务器上删除站点资源失败");
|
|
|
+ exceShellFailed("删除站点资源", adwebSite, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void exceShellFailed(String cmd, AdwebSite adwebSite, String errorMsg) {
|
|
|
+ SysException sysException = new SysException();
|
|
|
+
|
|
|
+ sysException.setType(1);
|
|
|
+ sysException.setFunctionModule(cmd);
|
|
|
+ sysException.setExceptionDetail(String.format("站点code:%s, 站点名称:%s,临时连接:%s", adwebSite.getCode(), adwebSite.getName(), adwebSite.getDomain()));
|
|
|
+ sysException.setExceptionDescription(errorMsg);
|
|
|
+
|
|
|
+ sysExceptionService.save(sysException);
|
|
|
+ }
|
|
|
+
|
|
|
private void createSiteFailed(AdwebSite adwebSite, String errorMsg) {
|
|
|
adwebSite.setStatus(4); // 临时站点创建失败
|
|
|
siteService.updateById(adwebSite);
|