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(); } }

fantesy LV17
3月24日
微信网友_7371218154688512 LV4
2月5日
a562571298 LV8
1月4日
LoveSummer LV6
2024年10月31日
yyh1252 LV8
2024年8月12日
全斐 LV6
2024年6月19日
yzyz0812 LV3
2024年5月23日
sunlea LV20
2024年5月10日
玖零定制问题修复 LV34
2024年4月4日
wanglinddad LV55
2024年3月28日

chengguo123
4月2日
暂无贡献等级
fantesy LV17
3月24日
docnnxxy688
3月22日
暂无贡献等级
1252590909 LV2
3月17日
952773464
3月10日
暂无贡献等级
微信网友_7398626323435520 LV2
2月25日
pxqtsht LV16
2月21日
空空的城 LV13
2月15日
微信网友_7371218154688512 LV4
2月5日
wyx065747 LV67
1月29日