Skip to content

Commit

Permalink
Killed or crashed daemon process kept in the registry until mvnd --st…
Browse files Browse the repository at this point in the history
…op is called #154
  • Loading branch information
ppalaga committed Oct 27, 2020
1 parent 59a9bba commit 6cbd5be
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions client/src/main/java/org/jboss/fuse/mvnd/client/DefaultClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,20 @@ public ExecutionResult execute(ClientOutput output, List<String> argv) {
final String template = " %36s %7s %5s %7s %5s %23s %s";
output.accept(null, String.format(template,
"UUID", "PID", "Port", "Status", "RSS", "Last activity", "Java home"));
registry.getAll().forEach(d -> output.accept(null, String.format(template,
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())));
for (DaemonInfo d : registry.getAll()) {
if (ProcessHandle.of(d.getPid()).isEmpty()) {
/* The process does not exist anymore - remove it from the registry */
registry.remove(d.getUid());
} else {
output.accept(null, String.format(template,
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);
}
boolean stop = args.remove("--stop");
Expand Down

0 comments on commit 6cbd5be

Please sign in to comment.