Search in sources :

Example 1 with LoggingServiceRegistry

use of org.gradle.internal.logging.services.LoggingServiceRegistry in project gradle by gradle.

the class ProviderConnection method createExecuter.

private BuildActionExecuter<ProviderOperationParameters> createExecuter(ProviderOperationParameters operationParameters, Parameters params) {
    LoggingManagerInternal loggingManager;
    BuildActionExecuter<BuildActionParameters> executer;
    if (Boolean.TRUE.equals(operationParameters.isEmbedded())) {
        loggingManager = loggingServices.getFactory(LoggingManagerInternal.class).create();
        loggingManager.captureSystemSources();
        executer = embeddedExecutor;
    } else {
        LoggingServiceRegistry loggingServices = LoggingServiceRegistry.newNestedLogging();
        loggingManager = loggingServices.getFactory(LoggingManagerInternal.class).create();
        InputStream standardInput = operationParameters.getStandardInput();
        ServiceRegistry clientServices = daemonClientFactory.createBuildClientServices(loggingServices.get(OutputEventListener.class), params.daemonParams, standardInput == null ? SafeStreams.emptyInput() : standardInput);
        executer = clientServices.get(DaemonClient.class);
    }
    return new LoggingBridgingBuildActionExecuter(new DaemonBuildActionExecuter(executer, params.daemonParams), loggingManager);
}
Also used : LoggingManagerInternal(org.gradle.internal.logging.LoggingManagerInternal) DaemonClient(org.gradle.launcher.daemon.client.DaemonClient) InputStream(java.io.InputStream) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) LoggingServiceRegistry(org.gradle.internal.logging.services.LoggingServiceRegistry) OutputEventListener(org.gradle.internal.logging.events.OutputEventListener) LoggingServiceRegistry(org.gradle.internal.logging.services.LoggingServiceRegistry)

Example 2 with LoggingServiceRegistry

use of org.gradle.internal.logging.services.LoggingServiceRegistry in project gradle by gradle.

the class DefaultConnection method initializeServices.

private void initializeServices(File gradleUserHomeDir) {
    NativeServices.initialize(gradleUserHomeDir);
    LoggingServiceRegistry loggingServices = LoggingServiceRegistry.newEmbeddableLogging();
    services = ServiceRegistryBuilder.builder().displayName("Connection services").parent(loggingServices).parent(NativeServices.getInstance()).provider(new ConnectionScopeServices(loggingServices)).build();
    adapter = services.get(ProtocolToModelAdapter.class);
    connection = services.get(ProviderConnection.class);
}
Also used : ProtocolToModelAdapter(org.gradle.tooling.internal.adapter.ProtocolToModelAdapter) LoggingServiceRegistry(org.gradle.internal.logging.services.LoggingServiceRegistry)

Example 3 with LoggingServiceRegistry

use of org.gradle.internal.logging.services.LoggingServiceRegistry in project gradle by gradle.

the class DaemonMain method doAction.

@Override
protected void doAction(String[] args, ExecutionListener listener) {
    //The first argument is not really used but it is very useful in diagnosing, i.e. running 'jps -m'
    if (args.length != 1) {
        invalidArgs("Following arguments are required: <gradle-version>");
    }
    // Read configuration from stdin
    List<String> startupOpts;
    File gradleHomeDir;
    File daemonBaseDir;
    int idleTimeoutMs;
    int periodicCheckIntervalMs;
    String daemonUid;
    List<File> additionalClassPath;
    KryoBackedDecoder decoder = new KryoBackedDecoder(new EncodedStream.EncodedInput(System.in));
    try {
        gradleHomeDir = new File(decoder.readString());
        daemonBaseDir = new File(decoder.readString());
        idleTimeoutMs = decoder.readSmallInt();
        periodicCheckIntervalMs = decoder.readSmallInt();
        daemonUid = decoder.readString();
        int argCount = decoder.readSmallInt();
        startupOpts = new ArrayList<String>(argCount);
        for (int i = 0; i < argCount; i++) {
            startupOpts.add(decoder.readString());
        }
        int additionalClassPathLength = decoder.readSmallInt();
        additionalClassPath = new ArrayList<File>(additionalClassPathLength);
        for (int i = 0; i < additionalClassPathLength; i++) {
            additionalClassPath.add(new File(decoder.readString()));
        }
    } catch (EOFException e) {
        throw new UncheckedIOException(e);
    }
    NativeServices.initialize(gradleHomeDir);
    DaemonServerConfiguration parameters = new DefaultDaemonServerConfiguration(daemonUid, daemonBaseDir, idleTimeoutMs, periodicCheckIntervalMs, startupOpts);
    LoggingServiceRegistry loggingRegistry = LoggingServiceRegistry.newCommandLineProcessLogging();
    LoggingManagerInternal loggingManager = loggingRegistry.newInstance(LoggingManagerInternal.class);
    DaemonServices daemonServices = new DaemonServices(parameters, loggingRegistry, loggingManager, new DefaultClassPath(additionalClassPath));
    File daemonLog = daemonServices.getDaemonLogFile();
    // Any logging prior to this point will not end up in the daemon log file.
    initialiseLogging(loggingManager, daemonLog);
    // Detach the process from the parent terminal/console
    ProcessEnvironment processEnvironment = daemonServices.get(ProcessEnvironment.class);
    processEnvironment.maybeDetachProcess();
    LOGGER.debug("Assuming the daemon was started with following jvm opts: {}", startupOpts);
    Daemon daemon = daemonServices.get(Daemon.class);
    daemon.start();
    try {
        DaemonContext daemonContext = daemonServices.get(DaemonContext.class);
        Long pid = daemonContext.getPid();
        daemonStarted(pid, daemon.getUid(), daemon.getAddress(), daemonLog);
        DaemonExpirationStrategy expirationStrategy = daemonServices.get(MasterExpirationStrategy.class);
        daemon.stopOnExpiration(expirationStrategy, parameters.getPeriodicCheckIntervalMs());
    } finally {
        daemon.stop();
    }
}
Also used : LoggingManagerInternal(org.gradle.internal.logging.LoggingManagerInternal) DefaultDaemonServerConfiguration(org.gradle.launcher.daemon.configuration.DefaultDaemonServerConfiguration) EncodedStream(org.gradle.process.internal.streams.EncodedStream) UncheckedIOException(org.gradle.api.UncheckedIOException) ProcessEnvironment(org.gradle.internal.nativeintegration.ProcessEnvironment) EntryPoint(org.gradle.launcher.bootstrap.EntryPoint) LoggingServiceRegistry(org.gradle.internal.logging.services.LoggingServiceRegistry) KryoBackedDecoder(org.gradle.internal.serialize.kryo.KryoBackedDecoder) DaemonServerConfiguration(org.gradle.launcher.daemon.configuration.DaemonServerConfiguration) DefaultDaemonServerConfiguration(org.gradle.launcher.daemon.configuration.DefaultDaemonServerConfiguration) DaemonContext(org.gradle.launcher.daemon.context.DaemonContext) Daemon(org.gradle.launcher.daemon.server.Daemon) DaemonServices(org.gradle.launcher.daemon.server.DaemonServices) EOFException(java.io.EOFException) File(java.io.File) DaemonExpirationStrategy(org.gradle.launcher.daemon.server.expiry.DaemonExpirationStrategy) DefaultClassPath(org.gradle.internal.classpath.DefaultClassPath)

Aggregations

LoggingServiceRegistry (org.gradle.internal.logging.services.LoggingServiceRegistry)3 LoggingManagerInternal (org.gradle.internal.logging.LoggingManagerInternal)2 EOFException (java.io.EOFException)1 File (java.io.File)1 InputStream (java.io.InputStream)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 DefaultClassPath (org.gradle.internal.classpath.DefaultClassPath)1 OutputEventListener (org.gradle.internal.logging.events.OutputEventListener)1 ProcessEnvironment (org.gradle.internal.nativeintegration.ProcessEnvironment)1 KryoBackedDecoder (org.gradle.internal.serialize.kryo.KryoBackedDecoder)1 ServiceRegistry (org.gradle.internal.service.ServiceRegistry)1 EntryPoint (org.gradle.launcher.bootstrap.EntryPoint)1 DaemonClient (org.gradle.launcher.daemon.client.DaemonClient)1 DaemonServerConfiguration (org.gradle.launcher.daemon.configuration.DaemonServerConfiguration)1 DefaultDaemonServerConfiguration (org.gradle.launcher.daemon.configuration.DefaultDaemonServerConfiguration)1 DaemonContext (org.gradle.launcher.daemon.context.DaemonContext)1 Daemon (org.gradle.launcher.daemon.server.Daemon)1 DaemonServices (org.gradle.launcher.daemon.server.DaemonServices)1 DaemonExpirationStrategy (org.gradle.launcher.daemon.server.expiry.DaemonExpirationStrategy)1 BuildActionParameters (org.gradle.launcher.exec.BuildActionParameters)1