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(); } }
最近下载更多
sunlea LV18
5月10日
玖零定制问题修复 LV34
4月4日
wanglinddad LV55
3月28日
hell1530 LV5
3月11日
ssw11111 LV2
2月26日
lironggang LV38
2月6日
森sdfgf LV8
2月4日
全栈小陈 LV4
1月21日
lilong007 LV20
1月16日
oulingqiao LV13
1月11日
最近浏览更多
qizl LV8
5月9日
sunlea LV18
5月9日
李俊雄 LV3
5月8日
kenhomeliu LV29
4月30日
xunzhen245 LV1
4月28日
sdbrk LV14
4月23日
荣》Cowboy LV12
4月11日
玖零定制问题修复 LV34
4月4日
xiaozhi丶 LV14
4月1日
微信网友_6927932988952576 LV12
3月29日