提交 2d1b8272 编写于 作者: 偏锋书生's avatar 偏锋书生

1

上级 53e70292
......@@ -18,13 +18,14 @@ public class ContextInit implements ApplicationContextAware, ServletContextAware
public static volatile String pagePath;// page页面存放的根目录
public static volatile String webRootPath;// Webroot所在目录
@Autowired
private SysGlobalMapper sysGlobalMapper;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
//SysGlobalMapper sysGlobalMapper = applicationContext.getBean(SysGlobalMapper.class);
// SysGlobalMapper sysGlobalMapper =
// applicationContext.getBean(SysGlobalMapper.class);
SysGlobal sysGlobal = sysGlobalMapper.selectById(1l);
if (sysGlobal != null) {
ConfigGlobleName.putAwsConfig(sysGlobal);
......@@ -35,7 +36,7 @@ public class ContextInit implements ApplicationContextAware, ServletContextAware
public void setServletContext(ServletContext servletContext) {
String realPath = servletContext.getRealPath("/");
ContextInit.webRootPath = realPath;// 配置根目录
String rootPath = Thread.currentThread().getContextClassLoader().getResource(".").getPath();
String rootPath = "";// Thread.currentThread().getContextClassLoader().getResource(".").getPath();//TODO在springjar独立运行时空指针,后面处理
String appPackage = servletContext.getInitParameter("tapestry.app-package");
ContextInit.pagePath = String.format("%s%s/pages", rootPath, appPackage.replace(".", "/"));
}
......
......@@ -114,22 +114,49 @@ public class FlinkConfig extends ParentPageBean<DevopsFlink> {
try {
String remoteDir = "~/flink/deploy";
conn.executeCommand("mkdir -p " + remoteDir);
conn.scpDir(localPath, remoteDir, "0744", new String[] {}, new String[] {});
Result result = conn
.executeCommand("sh " + remoteDir + "/package.sh prod-bigdata-flink01 prod-bigdata-flink02");
// TODO 不能打印日志
if (result.isSuc()) {
String message = result.getMessage();
if (message.contains("请手工执行distributeconf.sh")) {
Result disResult = conn.executeCommand(
"sh " + remoteDir + "/distributeconf.sh prod-bigdata-flink01 prod-bigdata-flink02");
if (disResult.isSuc()) {
// 安装成功改状态
for (DevopsFlink temp : list) {
temp.setIsInstall(YesOrNo.yes.name());
devopsFlinkMapper.updateByPrimaryKeySelective(temp);
conn.executeCommand("rm -rf ~/flink/*log ");
conn.scpDir(localPath, remoteDir, "0744", new String[] {}, new String[] {});// TODO 调试方便
conn.executeCommand(
"sh " + remoteDir + "/package.sh prod-bigdata-flink01 prod-bigdata-flink02 &>~/flink/installlog");
TimeAssist.reDoWaitInit("flinkconfig-install");
while (true) {
try {
boolean reDoWait = TimeAssist.reDoWait("flinkconfig-install", 9);// 9次512秒9分钟不到
if (reDoWait) {
break;
}
Result freeResult = conn.executeCommand("cat ~/flink/installlog");
if (freeResult.isSuc()) {
if (freeResult.getMessage().contains("请手工执行distributeconf.sh")) {// 执行完了
conn.executeCommand("sh " + remoteDir
+ "/distributeconf.sh prod-bigdata-flink01 prod-bigdata-flink02 &>~/flink/distributeconflog");
TimeAssist.reDoWaitInit("flinkconfig-distributeconf");
while (true) {
boolean reDoWait2 = TimeAssist.reDoWait("flinkconfig-distributeconf", 9);// 9次512秒9分钟不到
if (reDoWait2) {
break;
}
Result distributeconfResult = conn.executeCommand("cat ~/flink/distributeconflog");
if (distributeconfResult.isSuc()) {
if (distributeconfResult.getMessage().contains("部署成功")) {// 第二步成功
// 安装成功改状态
for (DevopsFlink temp : list) {
temp.setIsInstall(YesOrNo.yes.name());
devopsFlinkMapper.updateByPrimaryKeySelective(temp);
}
break;
} else if (distributeconfResult.getMessage().contains("部署失败")) {
break;
} else {
// 未完成,继续跑
}
}
}
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
} finally {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册