Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use err stream when purging logs during a build, fixes #604 #617

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,14 @@ public ExecutionResult execute(ClientOutput output, List<String> argv) {
try (DaemonRegistry registry = new DaemonRegistry(parameters.registry())) {
if (Environment.STATUS.removeCommandLineOption(args) != null) {
final String template = "%8s %7s %24s %7s %5s %23s %s";
output.accept(Message.log(String.format(template,
output.accept(Message.out(String.format(template,
"ID", "PID", "Address", "Status", "RSS", "Last activity", "Java home")));
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.getId());
} else {
output.accept(Message.log(String.format(template,
output.accept(Message.out(String.format(template,
d.getId(), d.getPid(), d.getAddress(), d.getState(),
OsUtils.kbTohumanReadable(OsUtils.findProcessRssInKb(d.getPid())),
LocalDateTime.ofInstant(
Expand All @@ -231,7 +231,7 @@ public ExecutionResult execute(ClientOutput output, List<String> argv) {
if (Environment.STOP.removeCommandLineOption(args) != null) {
DaemonInfo[] dis = registry.getAll().toArray(new DaemonInfo[0]);
if (dis.length > 0) {
output.accept(Message.display("Stopping " + dis.length + " running daemons"));
output.accept(Message.out("Stopping " + dis.length + " running daemons"));
for (DaemonInfo di : dis) {
try {
ProcessHandle.of(di.getPid()).ifPresent(ProcessHandle::destroyForcibly);
Expand All @@ -246,7 +246,7 @@ public ExecutionResult execute(ClientOutput output, List<String> argv) {
}
if (Environment.PURGE.removeCommandLineOption(args) != null) {
String result = purgeLogs();
output.accept(Message.display(result != null ? result : "Nothing to purge"));
output.accept(Message.out(result != null ? result : "Nothing to purge"));
return DefaultResult.success(argv);
}

Expand Down Expand Up @@ -327,7 +327,7 @@ public ExecutionResult execute(ClientOutput output, List<String> argv) {
} finally {
String msg = purgeMessage.get();
if (msg != null) {
output.accept(Message.display(msg));
output.accept(Message.err(msg));
}
}
}
Expand Down