Controlling Zino with systemd

This assumes:

  1. you have created a user zino

  2. the user zino has the home directory of /home/zino

  3. zino is installed in a virtualenv /home/zino/.zino

Copy the zino.service.example file, reproduced below, to /etc/systemd/system/zino.service.

[Unit]
Description=Zino
After=network.target

[Service]
User=root
Group=nogroup
WorkingDirectory=/home/zino
ExecStart=/home/zino/.zino/bin/zino --user zino
Restart=always
RestartSec=5
StandardOutput=journal
StandardError=journal
SyslogIdentifier=zino

[Install]
WantedBy=multi-user.target

To make systemd aware of the new unit, you should run:

sudo systemctl daemon-reload

To enable the new unit to start automatically at system boot, run:

sudo systemctl enable zino

To start Zino in the background now, run:

sudo systemctl start zino

This will start zino as root; zino will drop its root privileges by itself as soon as port 162 is open for listening.

Removing redundant timestamps in logs

When running under systemd, Zino’s log output is handled by systemd and is viewable through the journalctl program (e.g. journalctl -u zino -f to follow the logs continuously).

However, systemd will add its own timestamps to log lines it receives, while Zino’s default log format includes timestamps. It might therefore be desirable to change Zino’s log format when running under systemd. The default looks something like this:

zino.toml
 [logging.formatters.standard]
 format = "%(asctime)s - %(levelname)s - %(name)s (%(threadName)s) - %(message)s"

Which could easily be changed to this:

zino.toml
 [logging.formatters.standard]
 format = "%(levelname)s - %(name)s (%(threadName)s) - %(message)s"

See Configuring logging for more details on controlling Zino log output.