Archived
0

Zond:fix: расчет задержки запуска PingMonitor

This commit is contained in:
2017-07-24 02:02:54 +03:00
parent 149c9231ee
commit 9e63c503b9
2 changed files with 9 additions and 9 deletions

View File

@@ -1,7 +1,5 @@
package asys.zond; package asys.zond;
import asys.zond.shell.Shell;
public class PingMonitor { public class PingMonitor {
private static final long STEP_PING = 5000; private static final long STEP_PING = 5000;
private final long delayStart; private final long delayStart;

View File

@@ -86,7 +86,7 @@ public class ZondCommandHandler implements CommandHandler {
do { do {
int code = 0; int code = 0;
long deadTime = System.currentTimeMillis() + delay; long deadTime = 0;
try { try {
server = new Server(); server = new Server();
@@ -99,6 +99,7 @@ public class ZondCommandHandler implements CommandHandler {
flagForceRestartProcess = true; flagForceRestartProcess = true;
killProcess(); killProcess();
}); });
deadTime = (System.currentTimeMillis()/1000) + delay;
code = executor.execute(commandLine); code = executor.execute(commandLine);
} catch (ExecuteException e) { } catch (ExecuteException e) {
code = e.getExitValue(); code = e.getExitValue();
@@ -106,14 +107,19 @@ public class ZondCommandHandler implements CommandHandler {
Shell.getInstance().getOutput().println("Exception message: " + e.getMessage()); Shell.getInstance().getOutput().println("Exception message: " + e.getMessage());
code = -99; code = -99;
} }
long currTime = System.currentTimeMillis()/1000;
server.shutdown(); server.shutdown();
pingMonitor.stop(); pingMonitor.stop();
server = null; server = null;
Shell.getInstance().getOutput().println("Process finished. Code: " + code); Shell.getInstance().getOutput().println("Process finished. Code: " + code);
if (!pingMonitor.isCorrectShutdown()) { if (pingMonitor.isCorrectShutdown()) {
if (System.currentTimeMillis() <= deadTime && !flagManualKill) { flagForceRestartProcess = false;
_try = 0;
break;
} else {
if (currTime <= deadTime && !flagManualKill) {
Shell.getInstance().getOutput().println("[!] Premature end process."); Shell.getInstance().getOutput().println("[!] Premature end process.");
_try++; _try++;
if (_try < 2) { if (_try < 2) {
@@ -128,10 +134,6 @@ public class ZondCommandHandler implements CommandHandler {
} else { } else {
break; break;
} }
} else {
flagForceRestartProcess = false;
_try = 0;
break;
} }
} while (_try < 2); } while (_try < 2);