Zond: несколько фиксов
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
group = 'asys'
|
||||
version = '0.6.10-SNAPSHOT'
|
||||
version = '0.6.11-SNAPSHOT'
|
||||
|
||||
apply plugin: 'application'
|
||||
|
||||
|
||||
@@ -57,8 +57,10 @@ public class Main {
|
||||
Shell.getInstance().start(System.in, commandLine -> {
|
||||
if (commandLine.equalsIgnoreCase(":exit")) {
|
||||
Shell.getInstance().getOutput().println("force exit");
|
||||
watchdog.destroyProcess();
|
||||
// watchdog.destroyProcess();
|
||||
Shell.getInstance().shutdown();
|
||||
Main.shutdown();
|
||||
return;
|
||||
}
|
||||
pipeInputStream.write(commandLine+"\r\n");
|
||||
});
|
||||
@@ -66,17 +68,15 @@ public class Main {
|
||||
|
||||
Connector.getInstance().startReconnect();
|
||||
|
||||
int resultCode = executeProcess(args, Shell.getInstance().getOutput(), pipeInputStream);
|
||||
// int resultCode = executeProcess(args, Shell.getInstance().getOutput(), pipeInputStream);
|
||||
|
||||
Connector.getInstance().setNeedReconnect(false);
|
||||
Connector.getInstance().stopReconnect();
|
||||
Connector.getInstance().disconnect();
|
||||
|
||||
Shell.getInstance().shutdown();
|
||||
|
||||
System.out.println(Ansi.ansi().reset().newline()
|
||||
.fg(Color.GREEN).a("Process Finished. Code: ")
|
||||
.bold().fg(Color.WHITE).a(resultCode).reset());
|
||||
// Shell.getInstance().shutdown();
|
||||
//
|
||||
//
|
||||
// int resultCode = -2;
|
||||
// System.out.println(Ansi.ansi().reset().newline()
|
||||
// .fg(Color.GREEN).a("Process Finished. Code: ")
|
||||
// .bold().fg(Color.WHITE).a(resultCode).reset());
|
||||
}
|
||||
|
||||
private static int executeProcess(String[] args, PrintStream printStream, InputStream stdin) throws IOException {
|
||||
@@ -120,4 +120,10 @@ public class Main {
|
||||
Config.load(fis);
|
||||
fis.close();
|
||||
}
|
||||
|
||||
private static void shutdown() {
|
||||
Connector.getInstance().setNeedReconnect(false);
|
||||
Connector.getInstance().stopReconnect();
|
||||
Connector.getInstance().shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,12 +54,10 @@ public class Connector {
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (client.isConnected()) {
|
||||
public void shutdown() {
|
||||
log("Disconnect...");
|
||||
client.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public void setChannel(Channel channel) {
|
||||
this.channel = channel;
|
||||
|
||||
@@ -18,7 +18,16 @@ public class JlineProxySysOut extends PrintStream {
|
||||
|
||||
public void setConsoleReader(ConsoleReader consoleReader) {
|
||||
this.consoleReader = consoleReader;
|
||||
if (consoleReader != null) {
|
||||
this.writer = new PrintWriter(consoleReader.getOutput());
|
||||
} else {
|
||||
try {
|
||||
super.out.write('\r');
|
||||
super.out.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _print(String s) {
|
||||
@@ -47,12 +56,29 @@ public class JlineProxySysOut extends PrintStream {
|
||||
|
||||
@Override
|
||||
public void write(byte[] buf, int off, int len) {
|
||||
if (consoleReader != null) {
|
||||
if ((char) buf[len - 1] == '\n') len--; //TODO проверить в windows
|
||||
_print(new String(buf, off, len));
|
||||
} else {
|
||||
super.write(buf, off, len);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String x) {
|
||||
if (consoleReader != null) {
|
||||
_print(x);
|
||||
} else {
|
||||
super.print(x);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(String x) {
|
||||
if (consoleReader != null) {
|
||||
_print(x);
|
||||
} else {
|
||||
super.println(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
package asys.zond.shell;
|
||||
|
||||
import jline.console.ConsoleReader;
|
||||
import jline.internal.Ansi;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@@ -48,6 +49,7 @@ public class Shell {
|
||||
public void shutdown() {
|
||||
threadCommandHandler.interrupt();
|
||||
active = false;
|
||||
proxySysOut.setConsoleReader(null);
|
||||
}
|
||||
|
||||
public JlineProxySysOut getOutput() {
|
||||
|
||||
Reference in New Issue
Block a user