I’m replying to this because it’s the second hit on google for “keycloak systemd”
I did a lot of research on starting keycloak standalone using systemd, including the reviewing the information keycloak-15.0.1/docs/contrib/scripts. One note about the contrib scripts: they appear to be from the wildfly project and not specific to keycloak.
I Basically used the OP’s service file with a couple of changes:
I found the Type=idle and Timeout* fields did not appear to be needed. I think the key attribute is the WorkingDirectory= setting. I read the standalone.sh script and it does quite a few things based on the current directory.
Notes:
I’m unpacking keycloak into /opt
I created the keycloak user and group, and chown’d /opt/keycloak-15.0.1 with this user and group.
I’m not overriding the default of binding to 127.0.0.1 because I’m using nginx to reverse proxy, but that should be a simple change to the ExecStart= setting.
The above script is working for me on CentOS, and both starts and stops keycloak, and I have it enabled and it starts keycloak at boot.