Skip to content

Commit

Permalink
Add shutdownHook to send sigterm to ryuk (#7717)
Browse files Browse the repository at this point in the history
Currently, `Ryuk` container finishes after around 10s. This commit register
a shutdown hook which will send a sigterm to the Ryuk container when JVM
is terminating causing Ryuk to finish sooner.
  • Loading branch information
eddumelendez committed Oct 27, 2023
1 parent 95849a5 commit 39f0219
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ private synchronized void maybeStart() {

ryukContainer.start();

Runtime
.getRuntime()
.addShutdownHook(
new Thread(
DockerClientFactory.TESTCONTAINERS_THREAD_GROUP,
() -> {
this.dockerClient.killContainerCmd(this.ryukContainer.getContainerId())
.withSignal("SIGTERM")
.exec();
}
)
);

CountDownLatch ryukScheduledLatch = new CountDownLatch(1);

String host = ryukContainer.getHost();
Expand Down

0 comments on commit 39f0219

Please sign in to comment.