Commit 798d7f9c authored by Michael Menzel's avatar Michael Menzel

Argparse added, call flags added

parent 1c4fc8c9
...@@ -73,18 +73,20 @@ ...@@ -73,18 +73,20 @@
<artifactId>spring-boot-starter-thymeleaf</artifactId> <artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>2.1.3.RELEASE</version> <version>2.1.3.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
<version>2.1.3.RELEASE</version> <version>2.1.3.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sourceforge.nekohtml</groupId> <groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId> <artifactId>nekohtml</artifactId>
<version>1.9.22</version> <version>1.9.22</version>
</dependency> </dependency>
<dependency>
<groupId>net.sourceforge.argparse4j</groupId>
<artifactId>argparse4j</artifactId>
<version>0.8.1</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -67,7 +67,7 @@ public final class BackendConnector { ...@@ -67,7 +67,7 @@ public final class BackendConnector {
BackendConnector(String ip) { BackendConnector(String ip) {
this.port = 42412; this.port = Settings.getPort();
this.ip = ip; this.ip = ip;
id = clientID.getAndIncrement(); id = clientID.getAndIncrement();
......
...@@ -11,6 +11,7 @@ public class Settings { ...@@ -11,6 +11,7 @@ public class Settings {
private static String contigsPath; private static String contigsPath;
private static String backendip; private static String backendip;
private static Path statpath; private static Path statpath;
private static int port;
private static Logger logger = LoggerFactory.getLogger(StatisticsCollector.class); private static Logger logger = LoggerFactory.getLogger(StatisticsCollector.class);
...@@ -46,9 +47,17 @@ public class Settings { ...@@ -46,9 +47,17 @@ public class Settings {
public static void setContigsPath(String contigsPath) { public static void setContigsPath(String contigsPath) {
if (!new File(contigsPath).exists()) if (!new File(contigsPath).exists())
logger.error("Exception {}", "Contigs path missing", "The contigs path " + contigsPath + " is missing"); logger.error("Exception {}{}", "Contigs path missing", "The contigs path " + contigsPath + " is missing");
Settings.contigsPath = contigsPath; Settings.contigsPath = contigsPath;
} }
public static int getPort() {
return port;
}
public static void setPort(Integer ip) {
port = ip;
}
} }
...@@ -19,12 +19,18 @@ package de.thm.spring.run; ...@@ -19,12 +19,18 @@ package de.thm.spring.run;
import de.thm.spring.backend.Sessions; import de.thm.spring.backend.Sessions;
import de.thm.spring.backend.Settings; import de.thm.spring.backend.Settings;
import de.thm.spring.backend.StatisticsCollector; import de.thm.spring.backend.StatisticsCollector;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import static net.sourceforge.argparse4j.impl.Arguments.store;
/** /**
* Spring Server * Spring Server
* *
...@@ -39,18 +45,28 @@ public class Webinterface { ...@@ -39,18 +45,28 @@ public class Webinterface {
public static void main(String[] args) { public static void main(String[] args) {
if (args.length != 3) { Namespace input = null;
System.err.println("Incorrect number of arguments. Please specify the arguments according to the SETUPINSTR.md file.");
System.err.println("Exiting now"); ArgumentParser parser = ArgumentParsers.newFor("Enhort frontend").build()
System.exit(1); .defaultHelp(true)
} .description("Enhort frontend server");
parser.addArgument("--ip").help("IP to connect to").action(store()).required(true);
parser.addArgument("-p", "--port").help("Port connect to").setDefault(42412).action(store());
parser.addArgument("--contigs-path").help("Path to contigs files.").action(store()).required(true);
parser.addArgument("--stat-path").help("Path to store statistics.").setDefault("tmp").action(store());
/* Set up Settings */ try {
input = parser.parseArgs(args);
} catch (ArgumentParserException e) {
parser.handleError(e);
System.exit(1);
}
Settings.setBackendip(args[0]); Settings.setBackendip(input.getString("ip"));
Settings.setContigsPath(args[1]); Settings.setContigsPath(input.getString("contigs_path"));
Settings.setStatfile_path(args[2]); Settings.setStatfile_path(input.getString("stat_path"));
Settings.setPort(input.getInt("port"));
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment