use of org.gradle.launcher.daemon.registry.DaemonStopEvent in project gradle by gradle.
the class DefaultDaemonConnector method handleStopEvents.
private void handleStopEvents(Collection<DaemonInfo> idleDaemons, Collection<DaemonInfo> busyDaemons) {
final List<DaemonStopEvent> stopEvents = daemonRegistry.getStopEvents();
// Clean up old stop events
daemonRegistry.removeStopEvents(DaemonStopEvents.oldStopEvents(stopEvents));
final List<DaemonStopEvent> recentStopEvents = DaemonStopEvents.uniqueRecentDaemonStopEvents(stopEvents);
for (DaemonStopEvent stopEvent : recentStopEvents) {
Long pid = stopEvent.getPid();
LOGGER.info("Previous Daemon (" + (pid == null ? "PID unknown" : pid) + ") stopped at " + stopEvent.getTimestamp() + " " + stopEvent.getReason());
}
LOGGER.lifecycle(DaemonStartupMessage.generate(busyDaemons.size(), idleDaemons.size(), recentStopEvents.size()));
}
use of org.gradle.launcher.daemon.registry.DaemonStopEvent in project gradle by gradle.
the class ReportDaemonStatusClient method listAll.
public void listAll() {
final List<DaemonInfo> daemons = daemonRegistry.getAll();
final List<Status> statuses = Lists.newArrayList();
for (DaemonInfo daemon : daemons) {
DaemonClientConnection connection = connector.maybeConnect(daemon);
if (connection != null) {
try {
final ReportStatus statusCommand = new ReportStatus(idGenerator.generateId(), daemon.getToken());
final Status status = reportStatusDispatcher.dispatch(connection, statusCommand);
if (status != null) {
statuses.add(status);
} else {
// Handle failure
statuses.add(new Status(connection.getDaemon().getPid(), "UNKNOWN", "UNKNOWN"));
}
} finally {
connection.stop();
}
}
}
final List<DaemonStopEvent> stopEvents = DaemonStopEvents.uniqueRecentDaemonStopEvents(daemonRegistry.getStopEvents());
if (statuses.isEmpty()) {
LOGGER.quiet(DaemonMessages.NO_DAEMONS_RUNNING);
}
if (!(statuses.isEmpty() && stopEvents.isEmpty())) {
LOGGER.quiet(String.format(STATUS_FORMAT, "PID", "STATUS", "INFO"));
}
printRunningDaemons(statuses);
printStoppedDaemons(stopEvents);
LOGGER.quiet("");
LOGGER.quiet(STATUS_FOOTER + " See " + documentationRegistry.getDocumentationFor("gradle_daemon", "sec:status"));
}
use of org.gradle.launcher.daemon.registry.DaemonStopEvent in project gradle by gradle.
the class ReportDaemonStatusClient method printStoppedDaemons.
@VisibleForTesting
void printStoppedDaemons(final List<DaemonStopEvent> stopEvents) {
if (!stopEvents.isEmpty()) {
for (DaemonStopEvent event : stopEvents) {
Long pid = event.getPid();
LOGGER.quiet(String.format(STATUS_FORMAT, pid == null ? "PID unknown" : pid, "STOPPED", "(" + event.getReason() + ")"));
}
}
}
use of org.gradle.launcher.daemon.registry.DaemonStopEvent in project gradle by gradle.
the class DaemonRegistryUpdater method onExpire.
public void onExpire(String reason, DaemonExpirationStatus status) {
LOGGER.debug("Storing daemon stop event: {}", reason);
final Date timestamp = new Date(System.currentTimeMillis());
daemonRegistry.storeStopEvent(new DaemonStopEvent(timestamp, daemonContext.getPid(), status, reason));
}
Aggregations