PKI Systemd Service - dogtagpki/pki GitHub Wiki

Overview

Systemd can be used to run PKI server in the background as a Linux service.

Systemd Unit Files

Templates:

Targets:

Regular Systemd Service

When installed, each PKI instance will have a regular systemd service. The systemd service is defined at:

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

Nuxwdog Systemd Service

If Nuxwdog is enabled for this instance, the system service will be defined in

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:

Systemd Service Configuration

Instance-specific environment variables can be specified in /etc/sysconfig/pki-tomcat.

Enabling PKI Systemd Service

$ systemctl enable pki-tomcatd.target

See Also

⚠️ **GitHub.com Fallback** ⚠️