changed context
This commit is contained in:
parent
76203c50d9
commit
824b367701
@ -29,16 +29,16 @@ public class Main {
|
||||
public static void main(String[] args) throws Exception {
|
||||
AppConfig config = AppConfig.load();
|
||||
Database database = new Database(config);
|
||||
HttpServer server = HttpServer.create(new InetSocketAddress(config.listenHost, config.listenPort), 0);
|
||||
server.createContext(config.apiPath, new HeartbeatHandler(database));
|
||||
server.createContext("/", new DashboardHandler(config));
|
||||
server.createContext("/api/data", new DataApiHandler(database, config));
|
||||
HttpServer server = HttpServer.create(new InetSocketAddress("0.0.0.0", 8080), 0);
|
||||
server.createContext("/hb/api", new HeartbeatHandler(database));
|
||||
server.createContext("/hb/dashboard", new DashboardHandler(config));
|
||||
server.createContext("/hb/api/data", new DataApiHandler(database, config));
|
||||
server.setExecutor(null);
|
||||
server.start();
|
||||
|
||||
log("Listening on http://" + config.listenHost + ":" + config.listenPort);
|
||||
log("Dashboard: http://" + config.listenHost + ":" + config.listenPort + "/");
|
||||
log("API endpoint: " + config.apiPath);
|
||||
log("Listening on http://0.0.0.0:8080");
|
||||
log("Dashboard: http://0.0.0.0:8080/hb/dashboard");
|
||||
log("API endpoint: http://0.0.0.0:8080/hb/api");
|
||||
}
|
||||
|
||||
private static final class HeartbeatHandler implements HttpHandler {
|
||||
@ -94,18 +94,12 @@ public class Main {
|
||||
}
|
||||
|
||||
private static final class AppConfig {
|
||||
private final String listenHost;
|
||||
private final int listenPort;
|
||||
private final String apiPath;
|
||||
private final String jdbcUrl;
|
||||
private final String dbUser;
|
||||
private final String dbPassword;
|
||||
private final String dashboardApiKey;
|
||||
|
||||
private AppConfig(String listenHost, int listenPort, String apiPath, String jdbcUrl, String dbUser, String dbPassword, String dashboardApiKey) {
|
||||
this.listenHost = listenHost;
|
||||
this.listenPort = listenPort;
|
||||
this.apiPath = apiPath;
|
||||
private AppConfig(String jdbcUrl, String dbUser, String dbPassword, String dashboardApiKey) {
|
||||
this.jdbcUrl = jdbcUrl;
|
||||
this.dbUser = dbUser;
|
||||
this.dbPassword = dbPassword;
|
||||
@ -121,14 +115,11 @@ public class Main {
|
||||
properties.load(inputStream);
|
||||
}
|
||||
|
||||
String listenHost = properties.getProperty("server.host", "0.0.0.0");
|
||||
int listenPort = Integer.parseInt(properties.getProperty("server.port", "8080"));
|
||||
String apiPath = properties.getProperty("server.path", "/hb/api");
|
||||
String jdbcUrl = required(properties, "db.url");
|
||||
String dbUser = required(properties, "db.user");
|
||||
String dbPassword = required(properties, "db.password");
|
||||
String dashboardApiKey = required(properties, "dashboard.apiKey");
|
||||
return new AppConfig(listenHost, listenPort, apiPath, jdbcUrl, dbUser, dbPassword, dashboardApiKey);
|
||||
return new AppConfig(jdbcUrl, dbUser, dbPassword, dashboardApiKey);
|
||||
}
|
||||
|
||||
private static String required(Properties properties, String key) {
|
||||
|
||||
@ -1,9 +1,4 @@
|
||||
server.host=0.0.0.0
|
||||
server.port=8080
|
||||
server.path=/hb/api
|
||||
dashboard.apiKey=652f9h56gf32659twitf
|
||||
|
||||
db.url=jdbc:mariadb://10.0.0.147:3306/process_monitor?useUnicode=true&characterEncoding=utf8
|
||||
# Change these credentials before running.
|
||||
db.user=processmon
|
||||
db.password=process621420mon
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user