Search in sources :

Example 1 with StandaloneSonarLintImpl

use of org.sonarlint.daemon.services.StandaloneSonarLintImpl in project sonarlint-core by SonarSource.

the class Daemon method start.

public void start(int port, Path sonarlintHome) {
    try {
        LOGGER.info("Starting server on port {}", port);
        ServerInterceptor interceptor = new ExceptionInterceptor();
        server = NettyServerBuilder.forAddress(new InetSocketAddress("localhost", port)).addService(ServerInterceptors.intercept(new ConnectedSonarLintImpl(this), interceptor)).addService(ServerInterceptors.intercept(new StandaloneSonarLintImpl(this, Utils.getAnalyzers(sonarlintHome)), interceptor)).build().start();
        LOGGER.info("Server started, listening on {}", port);
        Runtime.getRuntime().addShutdownHook(new Thread() {

            @Override
            public void run() {
                LOGGER.info("JVM is shutting down");
                if (!server.isShutdown()) {
                    Daemon.this.stop();
                }
            }
        });
        server.awaitTermination();
    } catch (Exception e) {
        // grpc threads are daemon, so should not hang process
        LOGGER.error("Error running daemon", e);
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ServerInterceptor(io.grpc.ServerInterceptor) ExceptionInterceptor(org.sonarlint.daemon.interceptors.ExceptionInterceptor) StandaloneSonarLintImpl(org.sonarlint.daemon.services.StandaloneSonarLintImpl) ConnectedSonarLintImpl(org.sonarlint.daemon.services.ConnectedSonarLintImpl)

Aggregations

ServerInterceptor (io.grpc.ServerInterceptor)1 InetSocketAddress (java.net.InetSocketAddress)1 ExceptionInterceptor (org.sonarlint.daemon.interceptors.ExceptionInterceptor)1 ConnectedSonarLintImpl (org.sonarlint.daemon.services.ConnectedSonarLintImpl)1 StandaloneSonarLintImpl (org.sonarlint.daemon.services.StandaloneSonarLintImpl)1