Search in sources :

Example 1 with StopWhenIdle

use of org.gradle.launcher.daemon.protocol.StopWhenIdle in project gradle by gradle.

the class HandleStop method execute.

@Override
public void execute(DaemonCommandExecution execution) {
    if (execution.getCommand() instanceof Stop) {
        listenerBroadcast.onExpirationEvent(new DaemonExpirationResult(DaemonExpirationStatus.IMMEDIATE_EXPIRE, EXPIRATION_REASON));
        execution.getConnection().completed(new Success(null));
    } else if (execution.getCommand() instanceof StopWhenIdle) {
        hangShutdownForTesting();
        listenerBroadcast.onExpirationEvent(new DaemonExpirationResult(DaemonExpirationStatus.GRACEFUL_EXPIRE, EXPIRATION_REASON));
        execution.getConnection().completed(new Success(null));
    } else {
        execution.proceed();
    }
}
Also used : Stop(org.gradle.launcher.daemon.protocol.Stop) StopWhenIdle(org.gradle.launcher.daemon.protocol.StopWhenIdle) DaemonExpirationResult(org.gradle.launcher.daemon.server.expiry.DaemonExpirationResult) Success(org.gradle.launcher.daemon.protocol.Success)

Example 2 with StopWhenIdle

use of org.gradle.launcher.daemon.protocol.StopWhenIdle in project gradle by gradle.

the class DaemonStopClient method gracefulStop.

/**
 * Requests that the given daemons stop when idle. Does not block and returns before the daemons have all stopped.
 */
public void gracefulStop(Collection<DaemonConnectDetails> daemons) {
    for (DaemonConnectDetails daemon : daemons) {
        DaemonClientConnection connection = connector.maybeConnect(daemon);
        if (connection == null) {
            continue;
        }
        try {
            LOGGER.debug("Requesting daemon {} stop when idle", daemon);
            stopDispatcher.dispatch(connection, new StopWhenIdle(idGenerator.generateId(), connection.getDaemon().getToken()));
            LOGGER.lifecycle("Gradle daemon stopped.");
        } finally {
            connection.stop();
        }
    }
}
Also used : DaemonConnectDetails(org.gradle.launcher.daemon.context.DaemonConnectDetails) StopWhenIdle(org.gradle.launcher.daemon.protocol.StopWhenIdle)

Aggregations

StopWhenIdle (org.gradle.launcher.daemon.protocol.StopWhenIdle)2 DaemonConnectDetails (org.gradle.launcher.daemon.context.DaemonConnectDetails)1 Stop (org.gradle.launcher.daemon.protocol.Stop)1 Success (org.gradle.launcher.daemon.protocol.Success)1 DaemonExpirationResult (org.gradle.launcher.daemon.server.expiry.DaemonExpirationResult)1