PKI Systemd Service - dogtagpki/pki GitHub Wiki
Systemd can be used to run PKI server in the background as a Linux service.
Templates:
Targets:
-
/etc/systemd/system/pki-tomcatd.target.wants
-
/etc/systemd/system/pki-tomcatd-nuxwdog.target.wants
When installed, each PKI instance will have a regular systemd service. The systemd service is defined at:
-
/etc/systemd/system/pki-tomcatd.target.wants/[email protected]
which is a link to:
[Unit] Description=PKI Tomcat Server %i PartOf=pki-tomcatd.target [Service] Type=simple EnvironmentFile=/usr/share/pki/etc/tomcat.conf EnvironmentFile=/etc/tomcat/tomcat.conf Environment="NAME=%i" EnvironmentFile=-/etc/sysconfig/%i ExecStartPre=/usr/sbin/pki-server migrate --instance %i ExecStartPre=/usr/bin/pkidaemon start %i ExecStart=/usr/libexec/tomcat/server start ExecStop=/usr/libexec/tomcat/server stop SuccessExitStatus=143 User=pkiuser Group=pkiuser
The environment variables are stored in Tomcat configuration files. See also:
To start a service:
$ systemctl start pki-tomcatd@<instance>.service
To stop a service:
$ systemctl stop pki-tomcatd@<instance>.service
To check service status:
$ systemctl status pki-tomcatd@<instance>.service
If Nuxwdog is enabled for this instance, the system service will be defined in
-
/etc/systemd/system/pki-tomcatd-nuxwdog.target.wants/[email protected]
which is a link to:
[Unit] Description=PKI Tomcat Server %i Started by Nuxwdog PartOf=pki-tomcatd-nuxwdog.target [Service] Type=forking EnvironmentFile=/etc/tomcat/tomcat.conf Environment="NAME=%i" Environment="STARTED_BY_SYSTEMD=1" EnvironmentFile=-/etc/sysconfig/%i ExecStartPre=/usr/bin/pkidaemon start %i ExecStart=/bin/nuxwdog -f /etc/pki/%i/nuxwdog.conf SuccessExitStatus=143 TimeoutStartSec=180 PIDFile=/var/lib/pki/%i/logs/wd-%i.pid
Note: The -
on the EnvironmentFile
line ensures that no error messages is generated if the environment file does not exist. Since many of these files were optional in sysvinit, you should include the -
when using this directive.
See also:
Instance-specific environment variables can be specified in /etc/sysconfig/pki-tomcat
.
$ systemctl enable pki-tomcatd.target