|
|
@@ -276,6 +276,33 @@ public class Sftp {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ public Result deployMgrNode(String localDir, String remoteDir, RemoteHost remoteHost) {
|
|
|
+ Result result = Result.success();
|
|
|
+ try {
|
|
|
+ Session session = getSession(remoteHost);
|
|
|
+ upload(session, localDir, remoteDir);
|
|
|
+ log.info("files uploaded");
|
|
|
+
|
|
|
+ String command = String.format("cd %s && %s shutdown.sh && %s start.sh", remoteDir, bash, bash);
|
|
|
+ ShellResult shellResult = exec(session, command);
|
|
|
+ if (!shellResult.isSuccess()) {
|
|
|
+ String errMsg = String.format("start application failed\nexitCode: %s\nresult:\n%s", shellResult.getExitCode(), shellResult.getResult());
|
|
|
+ log.error(errMsg);
|
|
|
+ result = Result.fail(errMsg);
|
|
|
+ } else {
|
|
|
+ log.info("start application successfully");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (session.isConnected()) {
|
|
|
+ session.disconnect();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ result = Result.fail(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public ShellResult exec(RemoteHost remoteHost, String command) throws Exception {
|
|
|
Session session = getSession(remoteHost);
|
|
|
ShellResult shellResult = exec(session, command);
|