use of io.gravitee.gateway.services.monitoring.handler.MonitorHandler in project gravitee-gateway by gravitee-io.
the class MonitoringService method doStart.
@Override
protected void doStart() throws Exception {
if (enabled) {
super.doStart();
LOGGER.info("Start gateway monitor");
Event evt = prepareEvent();
LOGGER.debug("Sending a {} event", evt.getType());
heartbeatEvent = eventRepository.create(evt);
executorService = Executors.newSingleThreadScheduledExecutor(r -> new Thread(r, "gateway-monitor"));
MonitorThread monitorThread = new MonitorThread(heartbeatEvent);
this.applicationContext.getAutowireCapableBeanFactory().autowireBean(monitorThread);
LOGGER.info("Monitoring scheduled with fixed delay {} {} ", delay, unit.name());
((ScheduledExecutorService) executorService).scheduleWithFixedDelay(monitorThread, 0, delay, unit);
LOGGER.info("Associate a new HTTP handler on {}", PATH);
// Create and associate handler
MonitorHandler monitorHandler = new MonitorHandler();
applicationContext.getAutowireCapableBeanFactory().autowireBean(monitorHandler);
router.get(PATH).produces(MediaType.APPLICATION_JSON).handler(monitorHandler);
LOGGER.info("Start gateway monitor : DONE");
}
}
Aggregations