Package net.ishchenko.idea.nginx.configurator

Examples of net.ishchenko.idea.nginx.configurator.NginxServerDescriptor


    public NginxServerDescriptor createDescriptorFromFile(VirtualFile file) throws ThisIsNotNginxExecutableException {

        NginxCompileParameters compileParameters = NginxCompileParametersExtractor.extract(file);

        NginxServerDescriptor descriptor = getDefaultDescriptorFromFile(file);
        descriptor.setName("nginx/Windows [" + compileParameters.getVersion() + "]");

        String prefix;
        if (compileParameters.getPrefix() != null) {
            prefix = compileParameters.getPrefix();
            if (prefix.equals("")) {
                prefix = file.getParent().getPath();
            }
        } else {
            prefix = file.getParent().getPath(); // There is no default prefix for windows, so let it be current dir
        }

        descriptor.setConfigPath(getPrefixDependendSettings(compileParameters.getConfigurationPath(), prefix, DEFAULT_CONF_PATH));
        descriptor.setPidPath(getPrefixDependendSettings(compileParameters.getPidPath(), prefix, DEFAULT_PID_PATH));

        descriptor.setHttpLogPath(getPrefixDependendSettings(compileParameters.getHttpLogPath(), prefix, DEFAULT_HTTP_LOG_PATH));
        descriptor.setErrorLogPath(getPrefixDependendSettings(compileParameters.getErrorLogPath(), prefix, DEFAULT_ERROR_LOG_PATH));

        return descriptor;

    }
View Full Code Here


    }

    public NginxServerDescriptor getDefaultDescriptorFromFile(VirtualFile virtualFile) {

        NginxServerDescriptor result = new NginxServerDescriptor();
        result.setName("nginx/Windows [unknown version]");
        result.setExecutablePath(virtualFile.getPath());
        result.setConfigPath(virtualFile.getParent().getPath() + DEFAULT_CONF_PATH);
        result.setPidPath(virtualFile.getParent().getPath() + DEFAULT_PID_PATH);
        result.setHttpLogPath(virtualFile.getParent().getPath() + DEFAULT_HTTP_LOG_PATH);
        result.setErrorLogPath(virtualFile.getParent().getPath() + DEFAULT_ERROR_LOG_PATH);
        return result;

    }
View Full Code Here

    public static NginxProcessHandler create(NginxRunConfiguration config) throws ExecutionException {

        String descriptorId = config.getServerDescriptorId();

        NginxServerDescriptor descriptor = NginxServersConfiguration.getInstance().getDescriptorById(descriptorId);
        if (descriptor == null) {
            throw new ExecutionException(NginxBundle.message("run.error.servernotfound"));
        }

        NginxServerDescriptor descriptorCopy = descriptor.clone();

        VirtualFile executableVirtualFile = LocalFileSystem.getInstance().findFileByPath(descriptorCopy.getExecutablePath());
        if (executableVirtualFile == null || executableVirtualFile.isDirectory()) {
            throw new ExecutionException(NginxBundle.message("run.error.badpath", descriptorCopy.getExecutablePath()));
        }

        PlatformDependentTools pdt = ApplicationManager.getApplication().getComponent(PlatformDependentTools.class);

        ProcessBuilder builder = new ProcessBuilder(pdt.getStartCommand(descriptorCopy));
        builder.directory(new File(executableVirtualFile.getParent().getPath()));
        try {
            return new NginxProcessHandler(builder.start(), StringUtil.join(pdt.getStartCommand(descriptorCopy), " "), descriptorCopy.clone());
        } catch (IOException e) {
            throw new ExecutionException(e.getMessage(), e);
        }

    }
View Full Code Here

            final ConsoleView console = (ConsoleView) runContentDescriptor.getExecutionConsole();

            try {
                //the action will be disabled when there's no process handler, so no npe here. i hope...
                NginxProcessHandler processHandler = (NginxProcessHandler) runContentDescriptor.getProcessHandler();
                NginxServerDescriptor descriptor = processHandler.getDescriptor();

                //evil user may have deleted either server configuration
                validateDescriptor(descriptor);

                //it can be omitted for windows, but in linux we see silence if configuration file is invalid on reload
View Full Code Here

    public NginxServerDescriptor createDescriptorFromFile(VirtualFile file) throws ThisIsNotNginxExecutableException {

        NginxCompileParameters compileParameters = NginxCompileParametersExtractor.extract(file);

        NginxServerDescriptor descriptor = getDefaultDescriptorFromFile(file);
        descriptor.setName("nginx/Unix [" + compileParameters.getVersion() + "]");

        String prefix;
        if (compileParameters.getPrefix() != null) {
            prefix = compileParameters.getPrefix();
        } else {
            prefix = DEFAULT_PREFIX;
        }

        if (compileParameters.getConfigurationPath() != null) {
            descriptor.setConfigPath(compileParameters.getConfigurationPath());
        } else {
            descriptor.setConfigPath(prefix + DEFAULT_CONF_PATH);
        }

        if (compileParameters.getPidPath() != null) {
            descriptor.setPidPath(compileParameters.getPidPath());
        } else {
            descriptor.setPidPath(prefix + DEFAULT_PID_PATH);
        }

        if (compileParameters.getHttpLogPath() != null) {
            descriptor.setHttpLogPath(compileParameters.getHttpLogPath());
        } else {
            descriptor.setHttpLogPath(prefix + DEFAULT_HTTP_LOG_PATH);
        }

        if (compileParameters.getErrorLogPath() != null) {
            descriptor.setErrorLogPath(compileParameters.getErrorLogPath());
        } else {
            descriptor.setErrorLogPath(prefix + DEFAULT_ERROR_LOG_PATH);
        }

        return descriptor;

    }
View Full Code Here

        return descriptor;

    }

    public NginxServerDescriptor getDefaultDescriptorFromFile(VirtualFile virtualFile) {
        NginxServerDescriptor result = new NginxServerDescriptor();
        result.setName("nginx/Unix [unknown version]");
        result.setExecutablePath(virtualFile.getPath());
        result.setConfigPath(DEFAULT_PREFIX + DEFAULT_CONF_PATH);
        result.setPidPath(DEFAULT_PREFIX + DEFAULT_PID_PATH);
        result.setHttpLogPath(DEFAULT_PREFIX + DEFAULT_HTTP_LOG_PATH);
        result.setErrorLogPath(DEFAULT_PREFIX + DEFAULT_ERROR_LOG_PATH);
        return result;
    }
View Full Code Here

    @Override
    public void checkConfiguration() throws RuntimeConfigurationException {

        NginxServersConfiguration config = NginxServersConfiguration.getInstance();
        NginxServerDescriptor descriptor = config.getDescriptorById(serverDescriptorId);
        if (descriptor == null) {
            throw new RuntimeConfigurationException(NginxBundle.message("run.error.noserver"));
        }


        if (showHttpLog) {
            File accessLogFile = new File(httpLogPath);
            if (accessLogFile.isDirectory()) {
                throw new RuntimeConfigurationException("accesslog is directory");
            }
        }

        if (showErrorLog) {
            File errorLogFile = new File(errorLogPath);
            if (errorLogFile.isDirectory()) {
                throw new RuntimeConfigurationException("errorlog is directory");
            }
        }


        VirtualFile vfile = LocalFileSystem.getInstance().findFileByPath(descriptor.getExecutablePath());
        if (vfile == null) {
            throw new RuntimeConfigurationException(NginxBundle.message("run.error.badpath"));
        } else {

            PlatformDependentTools pdt = ApplicationManager.getApplication().getComponent(PlatformDependentTools.class);
View Full Code Here

        }

        public void applyEditorTo(NginxRunConfiguration s) {
            if (form.serverCombo.getSelectedItem() != null) {
                NginxServerDescriptor descriptor = (NginxServerDescriptor) form.serverCombo.getSelectedItem();
                s.setServerDescriptorId(descriptor.getId());
                s.setShowHttpLog(mediator.form.showHttpLogCheckBox.isSelected());
                s.setHttpLogPath(mediator.form.httpLogPathField.getText());
                s.setShowErrorLog(mediator.form.showErrorLogCheckBox.isSelected());
                s.setErrorLogPath(mediator.form.errorLogPathField.getText());
            }
View Full Code Here

                model.addElement(descriptor);
            }
            String chosenDescriptorId = configuration.getServerDescriptorId();
            if (chosenDescriptorId != null) {
                NginxServersConfiguration serversConfig = NginxServersConfiguration.getInstance();
                NginxServerDescriptor descriptor = serversConfig.getDescriptorById(chosenDescriptorId);
                if (descriptor != null) {
                    model.setSelectedItem(descriptor);
                } else {
                    model.setSelectedItem(null);
                }
View Full Code Here

    }

    public void checkConfiguration() throws RuntimeConfigurationException {

        NginxServersConfiguration config = NginxServersConfiguration.getInstance();
        NginxServerDescriptor descriptor = config.getDescriptorById(serverDescriptorId);
        if (descriptor == null) {
            throw new RuntimeConfigurationException(NginxBundle.message("run.error.noserver"));
        }


        if (showHttpLog) {
            File accessLogFile = new File(httpLogPath);
            if (accessLogFile.isDirectory()) {
                throw new RuntimeConfigurationException("accesslog is directory");
            }
        }

        if (showErrorLog) {
            File errorLogFile = new File(errorLogPath);
            if (errorLogFile.isDirectory()) {
                throw new RuntimeConfigurationException("errorlog is directory");
            }
        }


        VirtualFile vfile = LocalFileSystem.getInstance().findFileByPath(descriptor.getExecutablePath());
        if (vfile == null) {
            throw new RuntimeConfigurationException(NginxBundle.message("run.error.badpath"));
        } else {

            PlatformDependentTools pdt = ApplicationManager.getApplication().getComponent(PlatformDependentTools.class);
View Full Code Here

TOP

Related Classes of net.ishchenko.idea.nginx.configurator.NginxServerDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.