Zond: вернули функционал коннекта к асис
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
group = 'asys'
|
||||
version = '0.6.7-SNAPSHOT'
|
||||
version = '0.6.9-SNAPSHOT'
|
||||
|
||||
apply plugin: 'application'
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private static JlineProxySysOut proxySysOut;
|
||||
|
||||
private static void printLogo() {
|
||||
System.out.println(
|
||||
Ansi.ansi().reset()
|
||||
@@ -26,11 +28,14 @@ public class Main {
|
||||
}
|
||||
|
||||
public static void log(String message){
|
||||
System.out.println(
|
||||
Ansi.ansi().reset()
|
||||
String msg = Ansi.ansi().reset()
|
||||
.bg(Color.BLUE).fg(Color.WHITE).a("[ASys Zond] ")
|
||||
.a(message).reset()
|
||||
);
|
||||
.a(message).reset().toString();
|
||||
if (proxySysOut != null) {
|
||||
proxySysOut.println(msg);
|
||||
} else {
|
||||
System.out.println(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
@@ -48,7 +53,7 @@ public class Main {
|
||||
|
||||
loadConfig();
|
||||
|
||||
JlineProxySysOut proxySysOut = new JlineProxySysOut(System.out);
|
||||
proxySysOut = new JlineProxySysOut(System.out);
|
||||
JlineProxySysIn proxySysIn = new JlineProxySysIn();
|
||||
ConsoleReader console = new ConsoleReader(System.in, proxySysOut);
|
||||
proxySysOut.setConsoleReader(console);
|
||||
@@ -69,25 +74,26 @@ public class Main {
|
||||
proxySysIn.write(line+"\r\n");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(); //FIXME
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
});
|
||||
try {
|
||||
thread.join();
|
||||
thread.start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();//FIXME
|
||||
}
|
||||
|
||||
|
||||
// Connector.getInstance().startReconnect();
|
||||
Connector.getInstance().startReconnect();
|
||||
|
||||
int resultCode = executeProcess(args, proxySysOut, proxySysIn);
|
||||
|
||||
// Connector.getInstance().setNeedReconnect(false);
|
||||
// Connector.getInstance().stopReconnect();
|
||||
// Connector.getInstance().disconnect();
|
||||
Connector.getInstance().setNeedReconnect(false);
|
||||
Connector.getInstance().stopReconnect();
|
||||
Connector.getInstance().disconnect();
|
||||
|
||||
thread.interrupt();
|
||||
console.shutdown();
|
||||
|
||||
System.out.println(
|
||||
Ansi.ansi().reset().newline()
|
||||
@@ -102,10 +108,6 @@ public class Main {
|
||||
CommandLine commandLine = CommandLine.parse(cmdLine);
|
||||
DefaultExecutor executor = new DefaultExecutor();
|
||||
|
||||
// PrintStream proxySysOut = new ProxySysOut(System.out);
|
||||
// InputStream proxySysIn = new ProxySysIn();
|
||||
|
||||
// PumpStreamHandler psh = new PumpStreamHandler(proxySysOut, proxySysOut, proxySysIn);
|
||||
PumpStreamHandler psh = new PumpStreamHandler(printStream, printStream, stdin);
|
||||
psh.setStopTimeout(-1999); //hack: по-умолчанию в Apache Exec добавляется еще 2000L милисекунд
|
||||
executor.setStreamHandler(psh);
|
||||
@@ -142,33 +144,4 @@ public class Main {
|
||||
Config.load(fis);
|
||||
fis.close();
|
||||
}
|
||||
|
||||
private static class ProxySysOut extends PrintStream {
|
||||
ProxySysOut(OutputStream out) {
|
||||
super(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] buf, int off, int len) {
|
||||
super.write(buf, off, len);
|
||||
Connector.getInstance().sendMessage(new String(buf, off, len));
|
||||
}
|
||||
}
|
||||
|
||||
private static class ProxySysIn extends InputStream {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return System.in.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b) throws IOException {
|
||||
return System.in.read(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
return System.in.read(b, off, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user