WebOfTrust / keria

KERI Agent in the cloud
https://keria.readthedocs.io/en/latest/
Apache License 2.0
17 stars 26 forks source link

How to do graceful shutdown of KERIA #175

Open lenkan opened 5 months ago

lenkan commented 5 months ago

Currently, it seems like KERIA does not handle SIGTERM signals. Most container runtimes would send a SIGTERM signal, followed by a timeout of X seconds/minutes and then send a SIGKILL, which will not allow KERIA to gracefully shutdown.

Are there another recommended way to shutdown a KERIA instance? If not, I suggest to implement a SIGTERM listener that ensures we stop receiving new HTTP requests, then shutting down all the doers, allowing for the process to stop gracefully.

More urgently, do you see any potential issues with sending SIGKILL and killing the process immediately?

Any other thoughts on this?

One way to try this out is to use the docker-compose environment in signify-ts repo.

docker compose up keria
docker compose kill -s SIGTERM

Notice that keria does not shut down on its own. Then do:

docker compose kill -s SIGKILL

Keria then shuts down immediately.

kentbull commented 5 months ago

I would think there's a way to create a Doer in the HIO framework that HIO could process to close out the event loop. I suspect this will be a feature request to the HIO package. I will look through the source code there to see what I can find that would work as a shutdown signal.

I could see this being a Doer that listens for the SIGTERM signal and then instructing the core event loop to stop accepting new requests and to close down.

2byrds commented 2 months ago

From the keri dev meeting: Kent is working on this!