sulution 2 lab

This commit is contained in:
2026-10-29 20:26:49 +03:00
parent 65003b6119
commit e3a6372e91
32 changed files with 1455 additions and 38 deletions
+20
View File
@@ -0,0 +1,20 @@
import java.net.HttpURLConnection;
import java.net.URI;
/** Compiled in the build stage; works in a JRE without curl, shell parsing or extra packages. */
public class Healthcheck {
public static void main(String[] args) {
try {
String port = System.getenv().getOrDefault("APP_PORT", "8080");
HttpURLConnection connection = (HttpURLConnection) URI.create(
"http://127.0.0.1:" + port + "/health/ready").toURL().openConnection();
connection.setConnectTimeout(1000);
connection.setReadTimeout(1000);
int status = connection.getResponseCode();
connection.disconnect();
System.exit(status == 200 ? 0 : 1);
} catch (Exception exception) {
System.exit(1);
}
}
}