No Notification for health check in case service is unhealthy

Hi, I have implemented a simple web service and deployed it in Render to test the health check function for the “web service” service. I have a function that returns a response code 500 if the time (minutes) is in a certain time interval, otherwise I return a response code 200. During the specific time my service is not available and it seems that the service is trying to be restarted. Nevertheless, I do not receive an email. Here is my code for the health check endpoint:

Translated with DeepL.com (free version)
// Task Scheduler Bean
@Bean
public ThreadPoolTaskScheduler taskScheduler() {
return new ThreadPoolTaskScheduler();
}

// New Test Controller
@RestController
@RequestMapping("/test")
static class TestController {

	@GetMapping
	public void testEndpoint(HttpServletResponse response) throws IOException {
		LocalTime now = LocalTime.now();
		if (now.getMinute() % 10 == 0 || now.getMinute() % 10 < 4){
			response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Simulated Error");
		} else {
			response.setStatus(HttpServletResponse.SC_OK);
			response.getWriter().write("OK");
		}
	}
}

}

If the service is using a Free instance type, the service may be unavailable at times if it has spun down on idle. To look into this more deeply, we would need a service ID. If you’re uncomfortable sharing that publicly, we would recommend opening a ticket directly with us by using the “contact support” button at the bottom of your dashboard.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.