diff --git a/src/main/java/opendota/Main.java b/src/main/java/opendota/Main.java index 4a0709fe..9466bc8f 100644 --- a/src/main/java/opendota/Main.java +++ b/src/main/java/opendota/Main.java @@ -23,8 +23,9 @@ public class Main { public static void main(String[] args) throws Exception { - HttpServer server = HttpServer.create(new InetSocketAddress(Integer.valueOf(args.length > 0 ? args[0] : "5600")), 0); + HttpServer server = HttpServer.create(new InetSocketAddress(Integer.valueOf("5600")), 0); server.createContext("/", new MyHandler()); + server.createContext("/healthz", new HealthHandler()); server.createContext("/blob", new BlobHandler()); server.setExecutor(java.util.concurrent.Executors.newCachedThreadPool()); server.start(); @@ -52,6 +53,16 @@ public void handle(HttpExchange t) throws IOException { } } + static class HealthHandler implements HttpHandler { + @Override + public void handle(HttpExchange t) throws IOException { + t.sendResponseHeaders(200, 2); + OutputStream os = t.getResponseBody(); + os.write("ok".getBytes()); + os.close(); + } + } + static class BlobHandler implements HttpHandler { @Override public void handle(HttpExchange t) throws IOException { @@ -143,7 +154,7 @@ public void run() ip = RegisterTask.shellExec("hostname -i"); } int nproc = Runtime.getRuntime().availableProcessors(); - RegisterTask.shellExec("curl -X POST -L" + System.getenv().get("SERVICE_REGISTRY_HOST") + "/register/parser/" + ip + "?size=" + nproc); + RegisterTask.shellExec("curl -X POST -L" + System.getenv().get("SERVICE_REGISTRY_HOST") + "/register/parser/" + ip + ":5600" + "?size=" + nproc); } catch (Exception e) { System.err.println(e); }