Add System property ctbrec.server.mode on server startup

This property gets set by the server, so that we know,
if we are running in server mode or not
This commit is contained in:
0xboobface 2018-09-07 17:20:07 +02:00
parent 3cf3f2751e
commit 7cc5764461
2 changed files with 6 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -81,4 +82,8 @@ public class Config {
Files.createDirectories(configDir.toPath());
Files.write(configFile.toPath(), json.getBytes("utf-8"), CREATE, WRITE, TRUNCATE_EXISTING);
}
public boolean isServerMode() {
return Objects.equals(System.getProperty("ctbrec.server.mode"), "1");
}
}

View File

@ -26,6 +26,7 @@ public class HttpServer {
private Server server = new Server();
public HttpServer() throws Exception {
System.setProperty("ctbrec.server.mode", "1");
if(System.getProperty("ctbrec.config") == null) {
System.setProperty("ctbrec.config", "server.json");
}