Files
no-copy/src/main/java/ru/soune/nocopy/controller/HealtCheckController.java
T

53 lines
1.6 KiB
Java
Raw Normal View History

2025-12-10 19:12:54 +07:00
package ru.soune.nocopy.controller;
2025-12-08 12:38:56 +07:00
2026-02-11 19:15:16 +07:00
import org.springframework.beans.factory.annotation.Value;
2025-12-08 12:38:56 +07:00
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
2026-01-25 21:10:17 +07:00
import java.util.HashMap;
import java.util.Map;
2025-12-08 12:38:56 +07:00
@RestController
@RequestMapping("check/api")
2025-12-08 12:38:56 +07:00
public class HealtCheckController {
@GetMapping("/healt")
public HttpStatus healtCheck() {
return HttpStatus.OK;
}
2026-01-25 21:10:17 +07:00
2026-02-11 19:15:16 +07:00
@Value("${BUILD_TIME_BACK:unknown}")
private String buildTimeBack;
@GetMapping("/build")
public BuildInfo getBuildInfo() {
2026-02-11 19:50:07 +07:00
return new BuildInfo(buildTimeBack);
2026-02-11 19:15:16 +07:00
}
2026-01-25 21:10:17 +07:00
@GetMapping("/api/debug/memory")
public Map<String, String> getMemoryInfo() {
Runtime runtime = Runtime.getRuntime();
long mb = 1024 * 1024;
Map<String, String> info = new HashMap<>();
info.put("maxMemory (MB)", String.valueOf(runtime.maxMemory() / mb));
info.put("totalMemory (MB)", String.valueOf(runtime.totalMemory() / mb));
info.put("freeMemory (MB)", String.valueOf(runtime.freeMemory() / mb));
info.put("usedMemory (MB)", String.valueOf((runtime.totalMemory() - runtime.freeMemory()) / mb));
info.put("availableProcessors", String.valueOf(runtime.availableProcessors()));
info.put("JAVA_TOOL_OPTIONS", System.getenv("JAVA_TOOL_OPTIONS"));
info.put("JAVA_OPTS", System.getenv("JAVA_OPTS"));
return info;
}
2026-02-11 19:15:16 +07:00
static class BuildInfo {
public String buildTimeBack;
2026-02-11 19:50:07 +07:00
public BuildInfo(String buildTimeBack) {
2026-02-11 19:15:16 +07:00
this.buildTimeBack = buildTimeBack;
}
}
2025-12-08 12:38:56 +07:00
}