Killed or crashed daemon process kept in the registry until mvnd --stop is called #154

This commit is contained in:
Peter Palaga
2020-10-27 12:40:38 +01:00
parent 59a9bbad5b
commit 6cbd5be8b6

View File

@@ -154,13 +154,20 @@ public class DefaultClient implements Client {
final String template = " %36s %7s %5s %7s %5s %23s %s"; final String template = " %36s %7s %5s %7s %5s %23s %s";
output.accept(null, String.format(template, output.accept(null, String.format(template,
"UUID", "PID", "Port", "Status", "RSS", "Last activity", "Java home")); "UUID", "PID", "Port", "Status", "RSS", "Last activity", "Java home"));
registry.getAll().forEach(d -> output.accept(null, String.format(template, for (DaemonInfo d : registry.getAll()) {
d.getUid(), d.getPid(), d.getAddress(), d.getState(), if (ProcessHandle.of(d.getPid()).isEmpty()) {
OsUtils.kbTohumanReadable(OsUtils.findProcessRssInKb(d.getPid())), /* The process does not exist anymore - remove it from the registry */
LocalDateTime.ofInstant( registry.remove(d.getUid());
Instant.ofEpochMilli(Math.max(d.getLastIdle(), d.getLastBusy())), } else {
ZoneId.systemDefault()), output.accept(null, String.format(template,
d.getJavaHome()))); d.getUid(), d.getPid(), d.getAddress(), d.getState(),
OsUtils.kbTohumanReadable(OsUtils.findProcessRssInKb(d.getPid())),
LocalDateTime.ofInstant(
Instant.ofEpochMilli(Math.max(d.getLastIdle(), d.getLastBusy())),
ZoneId.systemDefault()),
d.getJavaHome()));
}
}
return new DefaultResult(argv, null); return new DefaultResult(argv, null);
} }
boolean stop = args.remove("--stop"); boolean stop = args.remove("--stop");