|
@ -1,14 +1,14 @@ |
|
|
package com.epmet.healthcheck; |
|
|
package com.epmet.healthcheck; |
|
|
|
|
|
|
|
|
import com.epmet.commons.tools.utils.IpUtils; |
|
|
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
import java.net.Inet4Address; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import java.net.InetAddress; |
|
|
|
|
|
import java.net.UnknownHostException; |
|
|
|
|
|
|
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("healthcheck") |
|
|
@RequestMapping("healthcheck") |
|
@ -20,10 +20,15 @@ public class HealthCheckController { |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("http") |
|
|
@PostMapping("http") |
|
|
public Result httpHealthCheck(HttpServletRequest request) { |
|
|
public Result httpHealthCheck() { |
|
|
String serverName = request.getServerName(); |
|
|
InetAddress serverIp = null; |
|
|
log.info("健康检查:serverName:{}", serverName); |
|
|
try { |
|
|
return new Result().ok(serverName); |
|
|
serverIp = Inet4Address.getLocalHost(); |
|
|
|
|
|
} catch (UnknownHostException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
log.info("健康检查:serverName:{}", serverIp); |
|
|
|
|
|
return new Result().ok(serverIp); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|