-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39206 from turing85/feature/add-shtudown-delay-an…
…d-teardown-readiness Improve graceful shutdown
- Loading branch information
Showing
34 changed files
with
262 additions
and
168 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
core/deployment/src/main/java/io/quarkus/deployment/shutdown/ShutdownBuildTimeConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.quarkus.deployment.shutdown; | ||
|
||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
@ConfigRoot(phase = ConfigPhase.BUILD_TIME) | ||
public class ShutdownBuildTimeConfig { | ||
|
||
/** | ||
* Whether Quarkus should wait between shutdown being requested and actually initiated. | ||
* This delay gives the infrastructure time to detect that the application instance is shutting down and | ||
* stop routing traffic to it. | ||
*/ | ||
@ConfigItem(defaultValue = "false") | ||
public boolean delayEnabled; | ||
} |
9 changes: 5 additions & 4 deletions
9
core/deployment/src/main/java/io/quarkus/deployment/steps/ShutdownListenerBuildStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
package io.quarkus.deployment.steps; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.ExecutionTime; | ||
import io.quarkus.deployment.annotations.Record; | ||
import io.quarkus.deployment.builditem.ShutdownListenerBuildItem; | ||
import io.quarkus.deployment.shutdown.ShutdownBuildTimeConfig; | ||
import io.quarkus.runtime.shutdown.ShutdownRecorder; | ||
|
||
public class ShutdownListenerBuildStep { | ||
|
||
@BuildStep | ||
@Record(ExecutionTime.RUNTIME_INIT) | ||
void setupShutdown(List<ShutdownListenerBuildItem> listeners, ShutdownRecorder recorder) { | ||
recorder.setListeners( | ||
listeners.stream().map(ShutdownListenerBuildItem::getShutdownListener).collect(Collectors.toList())); | ||
void setupShutdown(List<ShutdownListenerBuildItem> listeners, ShutdownBuildTimeConfig shutdownBuildTimeConfig, | ||
ShutdownRecorder recorder) { | ||
recorder.setListeners(listeners.stream().map(ShutdownListenerBuildItem::getShutdownListener).toList(), | ||
shutdownBuildTimeConfig.delayEnabled); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.