#65 daemon mode default output

This commit is contained in:
Andreas Penski (init) 2020-08-13 15:59:20 +02:00
parent f4509fd097
commit 8aa93158d1
3 changed files with 23 additions and 13 deletions

View file

@ -300,7 +300,7 @@ public class InputFactory {
*/ */
public static Input read(final InputStream inputStream, final String name, final String digestAlgorithm) { public static Input read(final InputStream inputStream, final String name, final String digestAlgorithm) {
checkNull(inputStream); checkNull(inputStream);
return read(new StreamSource(inputStream, name), digestAlgorithm); return read(new StreamSource(inputStream, name), name, digestAlgorithm);
} }
/** /**

View file

@ -123,12 +123,15 @@ public class Validator {
private static int startDaemonMode(final CommandLine cmd) { private static int startDaemonMode(final CommandLine cmd) {
final Option[] unavailable = new Option[] { PRINT, CHECK_ASSERTIONS, DEBUG, OUTPUT, EXTRACT_HTML, REPORT_POSTFIX, REPORT_PREFIX }; final Option[] unavailable = new Option[] { PRINT, CHECK_ASSERTIONS, DEBUG, OUTPUT, EXTRACT_HTML, REPORT_POSTFIX, REPORT_PREFIX };
warnUnusedOptions(cmd, unavailable, true); warnUnusedOptions(cmd, unavailable, true);
final ConfigurationLoader config = Configuration.load(determineDefinition(cmd), determineRepository(cmd)); final ConfigurationLoader config = getConfiguration(cmd);
final Daemon validDaemon = new Daemon(determineHost(cmd), determinePort(cmd), determineThreads(cmd)); final Daemon validDaemon = new Daemon(determineHost(cmd), determinePort(cmd), determineThreads(cmd));
if (cmd.hasOption(DISABLE_GUI.getOpt())) { if (cmd.hasOption(DISABLE_GUI.getOpt())) {
validDaemon.setGuiEnabled(false); validDaemon.setGuiEnabled(false);
} }
validDaemon.startServer(config.build()); final Configuration configuration = config.build();
printScenarios(configuration);
Printer.writeOut("\nStarting daemon mode ...");
validDaemon.startServer(configuration);
return DAEMON_SIGNAL; return DAEMON_SIGNAL;
} }
@ -146,11 +149,8 @@ public class Validator {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
final Option[] unavailable = new Option[] { HOST, PORT, WORKER_COUNT, DISABLE_GUI }; final Option[] unavailable = new Option[] { HOST, PORT, WORKER_COUNT, DISABLE_GUI };
warnUnusedOptions(cmd, unavailable, false); warnUnusedOptions(cmd, unavailable, false);
final URI scenarioLocation = determineDefinition(cmd); final Configuration config = getConfiguration(cmd).build();
final URI repositoryLocation = determineRepository(cmd); printScenarios(config);
reportConfiguration(scenarioLocation, repositoryLocation);
final Configuration config = Configuration.load(scenarioLocation, repositoryLocation).build();
final InternalCheck check = new InternalCheck(config); final InternalCheck check = new InternalCheck(config);
final Path outputDirectory = determineOutputDirectory(cmd); final Path outputDirectory = determineOutputDirectory(cmd);
@ -173,7 +173,6 @@ public class Validator {
if (cmd.hasOption(PRINT_MEM_STATS.getOpt())) { if (cmd.hasOption(PRINT_MEM_STATS.getOpt())) {
check.getCheckSteps().add(new PrintMemoryStats()); check.getCheckSteps().add(new PrintMemoryStats());
} }
printScenarios(check.getConfiguration());
log.info("Setup completed in {}ms\n", System.currentTimeMillis() - start); log.info("Setup completed in {}ms\n", System.currentTimeMillis() - start);
final Collection<Path> targets = determineTestTargets(cmd); final Collection<Path> targets = determineTestTargets(cmd);
@ -207,6 +206,13 @@ public class Validator {
} }
} }
private static ConfigurationLoader getConfiguration(final CommandLine cmd) {
final URI scenarioLocation = determineDefinition(cmd);
final URI repositoryLocation = determineRepository(cmd);
reportConfiguration(scenarioLocation, repositoryLocation);
return Configuration.load(scenarioLocation, repositoryLocation);
}
private static void reportConfiguration(final URI scenarioLocation, final URI repositoryLocation) { private static void reportConfiguration(final URI scenarioLocation, final URI repositoryLocation) {
Printer.writeOut("Loading scenarios from {0}", scenarioLocation); Printer.writeOut("Loading scenarios from {0}", scenarioLocation);
Printer.writeOut("Using repository {0}", repositoryLocation); Printer.writeOut("Using repository {0}", repositoryLocation);

View file

@ -44,16 +44,18 @@ public class Daemon {
/** /**
* Create a new daemon. * Create a new daemon.
*
* @param hostname the interface to bind to * @param hostname the interface to bind to
* @param port the port to expose * @param port the port to expose
* @param threadCount the number of working threads * @param threadCount the number of working threads
*/ */
public Daemon(final String hostname, final int port, final int threadCount) { public Daemon(final String hostname, final int port, final int threadCount) {
this.bindAddress = hostname; this.bindAddress = hostname;
this.port = port; this.port = port;
this.threadCount = threadCount; this.threadCount = threadCount;
} }
/** /**
* Methode zum Starten des Servers * Methode zum Starten des Servers
* *
@ -73,9 +75,7 @@ public class Daemon {
server.setExecutor(createExecutor()); server.setExecutor(createExecutor());
server.start(); server.start();
log.info("Server {} started", server.getAddress()); log.info("Server {} started", server.getAddress());
if (!log.isInfoEnabled()) { writeOut("Daemon started. Visit http://{0}", this.bindAddress + ":" + this.port);
writeOut("Server {0} started", server.getAddress());
}
} catch (final IOException e) { } catch (final IOException e) {
log.error("Error starting HttpServer for Valdidator: {}", e.getMessage(), e); log.error("Error starting HttpServer for Valdidator: {}", e.getMessage(), e);
} }
@ -101,4 +101,8 @@ public class Daemon {
private InetSocketAddress getSocket() { private InetSocketAddress getSocket() {
return new InetSocketAddress(defaultIfBlank(this.bindAddress, DEFAULT_HOST), this.port > 0 ? this.port : DEFAULT_PORT); return new InetSocketAddress(defaultIfBlank(this.bindAddress, DEFAULT_HOST), this.port > 0 ? this.port : DEFAULT_PORT);
} }
public static void shutdown() {
System.out.println("bla");
}
} }