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);
}
Aggregations