Recently I downloaded the new version Keycloak 17.0.0 Quarkus distribution, unzipped and started the Keycloak server by running bin/kc.sh start-dev
from my local $KEYCLOAK_HOME directory in a CygWin Bash window. The server is up and running and I have configured my initial admin user. I am also able to login to the Keycloak UI.
There is no cloud environment yet, no fancy configuration, it's only the bare standalone quarkus impl.
Question: How can I gracefull stop/quit/terminate the Keycloak server process? (Ctrl+C does not help in this case, because this command is not really scriptable)
Before moving to v17 I started my experiments with v16.1.0 Wildfly distribution and I was using ${KEYCLOAK_HOME}/bin/jboss-cli.sh --connect --commands="shutdown,quit"
to terminate the server. But v17 (quarkus) does not contain the jboss-cli.sh script.
Based on answer by Nathaniel Echols, my preferred solution is:
Start:
./keycloak-21.1.2/bin/kc.sh start-dev --http-port=8080 > keycloak.stdout 2>&1
echo -n "$!" > keycloak.pid
Stop:
cat keycloak.pid | xargs kill -INT
I use -INT
instead of -TERM
because then Keycloak has a chance to handle the request to stop. In keycloak.stdout
I see several messages that my custom providers close()
method was called, and, in the end
INFO [io.quarkus] (Shutdown thread) Keycloak stopped in 0.172s
So it looks that Keycloak was actually gracefully closed.
INT
is for sending the SIGINT
signal:
The SIGINT signal is sent to a process by its controlling terminal when a user wishes to interrupt the process. This is typically initiated by pressing Ctrl+C, but on some systems, the "delete" character or "break" key can be used.