mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-19 18:05:41 -05:00
fix(core): keep web up during graceful shutdown
The `@PreDestroy` hook is triggered very late in the lifecycle. Started the graceful clean using the global `ShutdownEvent`.
This commit is contained in:
committed by
Florian Hussonnois
parent
5ec869b1cc
commit
33628107c3
@@ -0,0 +1,34 @@
|
||||
package io.kestra.cli.listeners;
|
||||
|
||||
import io.kestra.worker.DefaultWorker;
|
||||
import io.micronaut.context.event.ApplicationEventListener;
|
||||
import io.micronaut.context.event.ShutdownEvent;
|
||||
import jakarta.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Global application shutdown handler.
|
||||
* This handler gets effectively invoked before {@link jakarta.annotation.PreDestroy} does.
|
||||
*/
|
||||
@Slf4j
|
||||
public class ShutdownListener implements ApplicationEventListener<ShutdownEvent> {
|
||||
@Inject
|
||||
DefaultWorker worker;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
**/
|
||||
@Override
|
||||
public void onApplicationEvent(ShutdownEvent event) {
|
||||
log.debug("Shutdown event received");
|
||||
worker.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
**/
|
||||
@Override
|
||||
public boolean supports(ShutdownEvent event) {
|
||||
return ApplicationEventListener.super.supports(event);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user