package com.dev; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.Properties; import org.springframework.core.io.support.PropertiesLoaderUtils; import com.dt.module.om.term.entity.Machine; import com.dt.module.om.term.websocket.SftpClient; import com.dt.module.om.util.RemoteShellExecutor; /** * @author: jinjie * @date: 2018年4月19日 下午2:38:43 * @Description: TODO */ public class DeployZcDevMac { /** * @Title: main * @Description: TODO * @param args * @return: void */ public static void main(String[] args) { String tomcatOnlyPort = "3037"; String dir = "/opt/tomcat/tomcat_shopuat/webapps"; String filename = "dt"; String rfile = dir + "/" + filename + ".war"; String fstr = "/Users/algernonking/" + filename + ".war"; PropertiesUtil p; String pwd = ""; try { p = new PropertiesUtil("/opt/autologin/conf.properties"); pwd = p.readValue("zc.rootpwd"); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } SftpClient sftp = new SftpClient(); Machine m = new Machine("localhost", "39.105.191.22", "root", pwd, 12500); sftp.connect(m, "upload"); sftp.changeDirectory("/tmp"); File f = new File(fstr); try { sftp.uploadFile(f, filename + ".war", null); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } RemoteShellExecutor executor = new RemoteShellExecutor("39.105.191.22", "root", pwd, 12500); // executor.exec("/usr/bin/cp " + rfile + " /tmp/shop." + filename + ".bak // --backup").print(); // 停应用 executor.exec("/usr/sbin/lsof -i:" + tomcatOnlyPort + " |awk '{print $2}' |grep -v PID|xargs kill -9 {} ") .print(); try { Thread.sleep(2000); } catch (Exception e) { e.printStackTrace(); } // 删除 executor.exec("rm -rf " + rfile).print(); try { Thread.sleep(1000); } catch (Exception e) { e.printStackTrace(); } // 覆盖 executor.exec("mv /tmp/" + filename + ".war " + dir + "/").print(); try { Thread.sleep(1000); } catch (Exception e) { e.printStackTrace(); } System.out.println("nohup sh " + dir + "/../bin/startup.sh;sleep 40 &"); executor.exec("nohup sh " + dir + "/../bin/startup.sh;sleep 40 &").print(); } }

date122 LV9
9月11日
code_loading LV5
9月9日
285443037 LV1
7月17日
woyaonao LV1
6月10日
刘孟飞 LV22
5月24日
fantesy LV17
3月24日
微信网友_7371218154688512 LV4
2月5日
a562571298 LV8
1月4日
LoveSummer LV6
2024年10月31日
yyh1252 LV8
2024年8月12日

date122 LV9
9月11日
code_loading LV5
9月9日
285443037 LV1
7月17日
woyaonao LV1
6月10日
刘孟飞 LV22
5月24日
chengguo123
4月2日
暂无贡献等级
fantesy LV17
3月24日
docnnxxy688
3月22日
暂无贡献等级
1252590909 LV2
3月17日
952773464
3月10日
暂无贡献等级