Skip to content

Starting siptrackd with systemd

Stefan Midjich edited this page Jul 22, 2017 · 2 revisions

Here is the service unit I'm using in production.

[Unit]
Description=Siptrackd - Inventory management backend server
ConditionPathExists=/var/opt/siptrack/siptrackd
After=network.target

[Service]
TimeoutStartSec=60
Type=simple
User=siptrack
Group=virtualenv
SyslogIdentifier=siptrackd
ExecStart=/var/opt/siptrack/venv/bin/python siptrackd --debug-logging -l - -b stmysql -s /etc/siptrackd_storage.cfg --searcher=whoosh --searcher-args=/var/opt/siptrack/siptrackd/st-whoosh --ssl-private-key=/etc/ssl/my.domain.key --ssl-certificate=/etc/ssl/certs/my.domain.pem
WorkingDirectory=/var/opt/siptrack/siptrackd

[Install]
WantedBy=multi-user.target

A few notes.

  • ConditionPathExists is almost superfluous but /var/opt/siptrack is $HOME of the siptrack user that runs the service, so that's more about good practice.
  • SyslogIdentifier is mostly to rename the process in the logs from python to something more relevant.
  • ExecStart requires of course to point to the python exe in your virtualenv, because using a virtualenv is good practice even in production imo. Path to the searcher is of course in the HOME of siptrack. SSL cert and key must be readable by the siptrack user.
  • WorkingDirectory is also probably superfluous but it can't hurt if you want to use relative paths.