Search in sources :

Example 1 with DockerCommandNotFoundException

use of org.eclipse.linuxtools.docker.core.DockerCommandNotFoundException in project linuxtools by eclipse.

the class DockerComposeUpJob method run.

@Override
protected IStatus run(final IProgressMonitor monitor) {
    final String dockerComposeInstallDir = Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.DOCKER_COMPOSE_INSTALLATION_DIRECTORY);
    final Thread commandThread = new Thread(() -> {
        // open console view
        ConsolePlugin.getDefault().getConsoleManager().showConsoleView(dockerComposeConsole);
        try {
            // run the 'docker-compose up' command
            final Process dockerComposeSystemProcess = DockerCompose.getInstance().up(this.connection, dockerComposeInstallDir, this.workingDir);
            final ILaunch launch = new Launch(launchConfiguration, ILaunchManager.RUN_MODE, null);
            final IProcess dockerComposeProcess = DebugPlugin.newProcess(launch, dockerComposeSystemProcess, // $NON-NLS-1$
            "docker-compose up");
            dockerComposeConsole.setDockerComposeProcess(// $NON-NLS-1$
            dockerComposeProcess);
            final int exitCode = dockerComposeSystemProcess.waitFor();
            if (exitCode != 0) {
                Display.getDefault().asyncExec(() -> MessageDialog.openError(Display.getDefault().getActiveShell(), JobMessages.getString(// $NON-NLS-1$
                "DockerCompose.dialog.title"), JobMessages.getString(// $NON-NLS-1$
                "DockerComposeUp.start.error")));
            }
        } catch (DockerCommandNotFoundException e) {
            // just display the error to the user, there's no need to report
            // an error in the log and in AERI for that.
            Display.getDefault().asyncExec(() -> MessageDialog.openError(Display.getCurrent().getActiveShell(), JobMessages.getString(// $NON-NLS-1$
            "DockerCompose.dialog.title"), e.getMessage()));
        } catch (DockerException | InterruptedException e) {
            Display.getDefault().asyncExec(() -> MessageDialog.openError(Display.getCurrent().getActiveShell(), JobMessages.getString(// $NON-NLS-1$
            "DockerCompose.dialog.title"), e.getMessage()));
            Activator.log(e);
        }
    });
    commandThread.start();
    return Status.OK_STATUS;
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) DockerCommandNotFoundException(org.eclipse.linuxtools.docker.core.DockerCommandNotFoundException) ILaunch(org.eclipse.debug.core.ILaunch) IProcess(org.eclipse.debug.core.model.IProcess) Launch(org.eclipse.debug.core.Launch) ILaunch(org.eclipse.debug.core.ILaunch) IProcess(org.eclipse.debug.core.model.IProcess)

Aggregations

ILaunch (org.eclipse.debug.core.ILaunch)1 Launch (org.eclipse.debug.core.Launch)1 IProcess (org.eclipse.debug.core.model.IProcess)1 DockerCommandNotFoundException (org.eclipse.linuxtools.docker.core.DockerCommandNotFoundException)1 DockerException (org.eclipse.linuxtools.docker.core.DockerException)1