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 {
|
public static void main(String[] args) throws Exception {
|
||||||
AppConfig config = AppConfig.load();
|
AppConfig config = AppConfig.load();
|
||||||
Database database = new Database(config);
|
Database database = new Database(config);
|
||||||
HttpServer server = HttpServer.create(new InetSocketAddress(config.listenHost, config.listenPort), 0);
|
HttpServer server = HttpServer.create(new InetSocketAddress("0.0.0.0", 8080), 0);
|
||||||
server.createContext(config.apiPath, new HeartbeatHandler(database));
|
server.createContext("/hb/api", new HeartbeatHandler(database));
|
||||||
server.createContext("/", new DashboardHandler(config));
|
server.createContext("/hb/dashboard", new DashboardHandler(config));
|
||||||
server.createContext("/api/data", new DataApiHandler(database, config));
|
server.createContext("/hb/api/data", new DataApiHandler(database, config));
|
||||||
server.setExecutor(null);
|
server.setExecutor(null);
|
||||||
server.start();
|
server.start();
|
||||||
|
|
||||||
log("Listening on http://" + config.listenHost + ":" + config.listenPort);
|
log("Listening on http://0.0.0.0:8080");
|
||||||
log("Dashboard: http://" + config.listenHost + ":" + config.listenPort + "/");
|
log("Dashboard: http://0.0.0.0:8080/hb/dashboard");
|
||||||
log("API endpoint: " + config.apiPath);
|
log("API endpoint: http://0.0.0.0:8080/hb/api");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class HeartbeatHandler implements HttpHandler {
|
private static final class HeartbeatHandler implements HttpHandler {
|
||||||
@ -94,18 +94,12 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final class AppConfig {
|
private static final class AppConfig {
|
||||||
private final String listenHost;
|
|
||||||
private final int listenPort;
|
|
||||||
private final String apiPath;
|
|
||||||
private final String jdbcUrl;
|
private final String jdbcUrl;
|
||||||
private final String dbUser;
|
private final String dbUser;
|
||||||
private final String dbPassword;
|
private final String dbPassword;
|
||||||
private final String dashboardApiKey;
|
private final String dashboardApiKey;
|
||||||
|
|
||||||
private AppConfig(String listenHost, int listenPort, String apiPath, String jdbcUrl, String dbUser, String dbPassword, String dashboardApiKey) {
|
private AppConfig(String jdbcUrl, String dbUser, String dbPassword, String dashboardApiKey) {
|
||||||
this.listenHost = listenHost;
|
|
||||||
this.listenPort = listenPort;
|
|
||||||
this.apiPath = apiPath;
|
|
||||||
this.jdbcUrl = jdbcUrl;
|
this.jdbcUrl = jdbcUrl;
|
||||||
this.dbUser = dbUser;
|
this.dbUser = dbUser;
|
||||||
this.dbPassword = dbPassword;
|
this.dbPassword = dbPassword;
|
||||||
@ -121,14 +115,11 @@ public class Main {
|
|||||||
properties.load(inputStream);
|
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 jdbcUrl = required(properties, "db.url");
|
||||||
String dbUser = required(properties, "db.user");
|
String dbUser = required(properties, "db.user");
|
||||||
String dbPassword = required(properties, "db.password");
|
String dbPassword = required(properties, "db.password");
|
||||||
String dashboardApiKey = required(properties, "dashboard.apiKey");
|
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) {
|
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
|
dashboard.apiKey=652f9h56gf32659twitf
|
||||||
|
|
||||||
db.url=jdbc:mariadb://10.0.0.147:3306/process_monitor?useUnicode=true&characterEncoding=utf8
|
db.url=jdbc:mariadb://10.0.0.147:3306/process_monitor?useUnicode=true&characterEncoding=utf8
|
||||||
# Change these credentials before running.
|
|
||||||
db.user=processmon
|
db.user=processmon
|
||||||
db.password=process621420mon
|
db.password=process621420mon
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user