Search in sources :

Example 1 with WorkerProcess

use of org.gradle.process.internal.worker.WorkerProcess in project gradle by gradle.

the class WorkerDaemonStarter method startDaemon.

public WorkerDaemonClient startDaemon(Class<? extends WorkerProtocol> workerProtocolImplementationClass, File workingDir, DaemonForkOptions forkOptions) {
    LOG.debug("Starting Gradle worker daemon with fork options {}.", forkOptions);
    Timer clock = Timers.startTimer();
    MultiRequestWorkerProcessBuilder<WorkerDaemonProcess> builder = workerDaemonProcessFactory.multiRequestWorker(WorkerDaemonProcess.class, WorkerProtocol.class, workerProtocolImplementationClass);
    builder.setBaseName("Gradle Worker Daemon");
    // NOTE: might make sense to respect per-compile-task log level
    builder.setLogLevel(startParameter.getLogLevel());
    builder.applicationClasspath(forkOptions.getClasspath());
    builder.sharedPackages(forkOptions.getSharedPackages());
    JavaExecHandleBuilder javaCommand = builder.getJavaCommand();
    javaCommand.setMinHeapSize(forkOptions.getMinHeapSize());
    javaCommand.setMaxHeapSize(forkOptions.getMaxHeapSize());
    javaCommand.setJvmArgs(forkOptions.getJvmArgs());
    javaCommand.setWorkingDir(workingDir);
    WorkerDaemonProcess workerDaemonProcess = builder.build();
    WorkerProcess workerProcess = workerDaemonProcess.start();
    WorkerDaemonClient client = new WorkerDaemonClient(forkOptions, workerDaemonProcess, workerProcess, buildOperationExecutor);
    LOG.info("Started Gradle worker daemon ({}) with fork options {}.", clock.getElapsed(), forkOptions);
    return client;
}
Also used : WorkerProcess(org.gradle.process.internal.worker.WorkerProcess) Timer(org.gradle.internal.time.Timer) JavaExecHandleBuilder(org.gradle.process.internal.JavaExecHandleBuilder)

Example 2 with WorkerProcess

use of org.gradle.process.internal.worker.WorkerProcess in project gradle by gradle.

the class WorkerDaemonStarter method startDaemon.

public WorkerDaemonClient startDaemon(DaemonForkOptions forkOptions, Action<WorkerProcess> cleanupAction) {
    LOG.debug("Starting Gradle worker daemon with fork options {}.", forkOptions);
    Timer clock = Time.startTimer();
    MultiRequestWorkerProcessBuilder<TransportableActionExecutionSpec, DefaultWorkResult> builder = workerDaemonProcessFactory.multiRequestWorker(WorkerDaemonServer.class);
    builder.setBaseName("Gradle Worker Daemon");
    // NOTE: might make sense to respect per-compile-task log level
    builder.setLogLevel(loggingManager.getLevel());
    builder.sharedPackages("org.gradle", "javax.inject");
    if (forkOptions.getClassLoaderStructure() instanceof FlatClassLoaderStructure) {
        FlatClassLoaderStructure flatClassLoaderStructure = (FlatClassLoaderStructure) forkOptions.getClassLoaderStructure();
        builder.applicationClasspath(classPathRegistry.getClassPath("MINIMUM_WORKER_RUNTIME").getAsFiles());
        builder.useApplicationClassloaderOnly();
        builder.applicationClasspath(toFiles(flatClassLoaderStructure.getSpec()));
    } else {
        builder.applicationClasspath(classPathRegistry.getClassPath("CORE_WORKER_RUNTIME").getAsFiles());
    }
    builder.onProcessFailure(cleanupAction);
    JavaExecHandleBuilder javaCommand = builder.getJavaCommand();
    forkOptions.getJavaForkOptions().copyTo(javaCommand);
    builder.registerArgumentSerializer(TransportableActionExecutionSpec.class, new TransportableActionExecutionSpecSerializer());
    MultiRequestClient<TransportableActionExecutionSpec, DefaultWorkResult> workerDaemonProcess = builder.build();
    WorkerProcess workerProcess = workerDaemonProcess.start();
    WorkerDaemonClient client = new WorkerDaemonClient(forkOptions, workerDaemonProcess, workerProcess, loggingManager.getLevel(), actionExecutionSpecFactory);
    LOG.info("Started Gradle worker daemon ({}) with fork options {}.", clock.getElapsed(), forkOptions);
    return client;
}
Also used : WorkerProcess(org.gradle.process.internal.worker.WorkerProcess) Timer(org.gradle.internal.time.Timer) JavaExecHandleBuilder(org.gradle.process.internal.JavaExecHandleBuilder)

Example 3 with WorkerProcess

use of org.gradle.process.internal.worker.WorkerProcess in project gradle by gradle.

the class PlayApplicationRunner method start.

public PlayApplicationRunnerToken start(PlayRunSpec spec) {
    WorkerProcess process = createWorkerProcess(spec.getProjectPath(), workerFactory, spec, adapter);
    process.start();
    PlayWorkerClient clientCallBack = new PlayWorkerClient();
    process.getConnection().addIncoming(PlayRunWorkerClientProtocol.class, clientCallBack);
    PlayRunWorkerServerProtocol workerServer = process.getConnection().addOutgoing(PlayRunWorkerServerProtocol.class);
    process.getConnection().connect();
    PlayAppLifecycleUpdate result = clientCallBack.waitForRunning();
    if (result.isRunning()) {
        return new PlayApplicationRunnerToken(workerServer, clientCallBack, process);
    } else {
        throw new GradleException("Unable to start Play application.", result.getException());
    }
}
Also used : WorkerProcess(org.gradle.process.internal.worker.WorkerProcess) GradleException(org.gradle.api.GradleException)

Example 4 with WorkerProcess

use of org.gradle.process.internal.worker.WorkerProcess in project gradle by gradle.

the class WorkerDaemonStarter method startDaemon.

public <T extends WorkSpec> WorkerDaemonClient startDaemon(Class<? extends WorkerProtocol<ActionExecutionSpec>> workerProtocolImplementationClass, DaemonForkOptions forkOptions) {
    LOG.debug("Starting Gradle worker daemon with fork options {}.", forkOptions);
    Timer clock = Time.startTimer();
    MultiRequestWorkerProcessBuilder<WorkerDaemonProcess> builder = workerDaemonProcessFactory.multiRequestWorker(WorkerDaemonProcess.class, WorkerProtocol.class, workerProtocolImplementationClass);
    builder.setBaseName("Gradle Worker Daemon");
    // NOTE: might make sense to respect per-compile-task log level
    builder.setLogLevel(loggingManager.getLevel());
    builder.applicationClasspath(forkOptions.getClasspath());
    builder.sharedPackages(forkOptions.getSharedPackages());
    JavaExecHandleBuilder javaCommand = builder.getJavaCommand();
    forkOptions.getJavaForkOptions().copyTo(javaCommand);
    WorkerDaemonProcess workerDaemonProcess = builder.build();
    WorkerProcess workerProcess = workerDaemonProcess.start();
    WorkerDaemonClient client = new WorkerDaemonClient(forkOptions, workerDaemonProcess, workerProcess, loggingManager.getLevel());
    LOG.info("Started Gradle worker daemon ({}) with fork options {}.", clock.getElapsed(), forkOptions);
    return client;
}
Also used : WorkerProcess(org.gradle.process.internal.worker.WorkerProcess) Timer(org.gradle.internal.time.Timer) JavaExecHandleBuilder(org.gradle.process.internal.JavaExecHandleBuilder)

Example 5 with WorkerProcess

use of org.gradle.process.internal.worker.WorkerProcess in project gradle by gradle.

the class PlayApplicationRunner method start.

public PlayApplication start(PlayRunSpec spec, Deployment deployment) {
    WorkerProcess process = createWorkerProcess(spec.getProjectPath(), workerFactory, spec, adapter);
    process.start();
    PlayRunWorkerServerProtocol workerServer = process.getConnection().addOutgoing(PlayRunWorkerServerProtocol.class);
    PlayApplication playApplication = new PlayApplication(new PlayClassloaderMonitorDeploymentDecorator(deployment, spec, adapter), workerServer, process);
    process.getConnection().addIncoming(PlayRunWorkerClientProtocol.class, playApplication);
    process.getConnection().connect();
    playApplication.waitForRunning();
    return playApplication;
}
Also used : WorkerProcess(org.gradle.process.internal.worker.WorkerProcess)

Aggregations

WorkerProcess (org.gradle.process.internal.worker.WorkerProcess)5 Timer (org.gradle.internal.time.Timer)3 JavaExecHandleBuilder (org.gradle.process.internal.JavaExecHandleBuilder)3 GradleException (org.gradle.api.GradleException)1