Search in sources :

Example 1 with CommandFactory

use of org.sonar.application.command.CommandFactory in project sonarqube by SonarSource.

the class App method start.

public void start(String[] cliArguments) {
    AppSettingsLoader settingsLoader = new AppSettingsLoaderImpl(System2.INSTANCE, cliArguments, new ServiceLoaderWrapper());
    AppSettings settings = settingsLoader.load();
    // order is important - logging must be configured before any other components (AppFileSystem, ...)
    AppLogging logging = new AppLogging(settings);
    logging.configure();
    AppFileSystem fileSystem = new AppFileSystem(settings);
    try (AppState appState = new AppStateFactory(settings).create()) {
        appState.registerSonarQubeVersion(getSonarqubeVersion());
        appState.registerClusterName(settings.getProps().nonNullValue(CLUSTER_NAME.getKey()));
        AppReloader appReloader = new AppReloaderImpl(settingsLoader, fileSystem, appState, logging);
        fileSystem.reset();
        CommandFactory commandFactory = new CommandFactoryImpl(settings.getProps(), fileSystem.getTempDir(), System2.INSTANCE);
        try (ProcessLauncher processLauncher = new ProcessLauncherImpl(fileSystem.getTempDir())) {
            Scheduler scheduler = new SchedulerImpl(settings, appReloader, commandFactory, processLauncher, appState);
            scheduler.schedule();
            stopRequestWatcher = StopRequestWatcherImpl.create(settings, scheduler, fileSystem);
            hardStopRequestWatcher = HardStopRequestWatcherImpl.create(scheduler, fileSystem);
            // intercepts CTRL-C
            Runtime.getRuntime().addShutdownHook(new ShutdownHook(scheduler));
            stopRequestWatcher.startWatching();
            hardStopRequestWatcher.startWatching();
            scheduler.awaitTermination();
            hardStopRequestWatcher.stopWatching();
        }
    } catch (Exception e) {
        Loggers.get(App.class).error("Startup failure", e);
    }
    systemExit.exit(0);
}
Also used : CommandFactoryImpl(org.sonar.application.command.CommandFactoryImpl) AppSettings(org.sonar.application.config.AppSettings) AppSettingsLoader(org.sonar.application.config.AppSettingsLoader) AppSettingsLoaderImpl(org.sonar.application.config.AppSettingsLoaderImpl) CommandFactory(org.sonar.application.command.CommandFactory) ServiceLoaderWrapper(org.sonar.core.extension.ServiceLoaderWrapper)

Aggregations

CommandFactory (org.sonar.application.command.CommandFactory)1 CommandFactoryImpl (org.sonar.application.command.CommandFactoryImpl)1 AppSettings (org.sonar.application.config.AppSettings)1 AppSettingsLoader (org.sonar.application.config.AppSettingsLoader)1 AppSettingsLoaderImpl (org.sonar.application.config.AppSettingsLoaderImpl)1 ServiceLoaderWrapper (org.sonar.core.extension.ServiceLoaderWrapper)1