Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

systemd

What is it?

systemd is the (newish) overall linux control program for managing programs and services (like web servers)

It handles:

  • Starting services (like firewall and reverse proxy)
  • Getting to sequence of program starts correct
  • Running programs periodically if desired
  • Restarting ptograms after errors
  • Logging status and problems

More information on Debian


Basic systemd commands

  • status
    • e.g. systemctl status ufw.service shows status of ufw (firewall)
    • Need to press Ctrl-C to exit
  • start | stop
    • e.g. systemctl stop caddy.service to stop caddy
    • __start__and stop state do not persist after reboot
    • stop will stop the service
    • restart often can stop and start, but check status since not all services manage this well
  • enable | disable
    • e.g. systemctl enable owserver
    • sets the service to be started after every reboot
    • Also start the service to get it started now, not just after a reboot
    • disable to set the service to not start on reboot

ufw firewall

systemd files installed by default. No changes should be needed.


caddy reverse-proxy

systemd files installed by default. No changes should be needed.


owserver 1-wire server

systemd files installed by default.

Note that the default owserver configuration gives fake example sensors, so will need real hardware and configuration file changes (and restart of the service__) to provide more than testing input.


owpost

For the local sensor-posting machine

The install script will add the following files to /etc/systemd/system

Timer (owpost.timer)

[Unit]
Description=Run owpost periotically to send data to owlogger

[Timer]
OnBootSec=3min
OnActiveSec=15min
Unit=owpost.service

[Install]
WantedBy=timers.target

Service (owpost.service)

[Unit]
Description=Post 1-wire data from owserver to remote owlogger
After=owserver.service
Requires=owserver.service

[Service]
Type=oneshot
# With configuration file in /etc/owlogger/owpost.toml
ExecStart=/usr/bin/python3 /usr/local/bin/owpost.py
# If no configuration file
# ExecStart=/usr/bin/python3 /usr/local/bin/owpost.py -o localhost:3504 -s https://remote.host:8001

owserver

  1. configure owserver
  2. start owserver
  • systemctl enable owserver
  • systemctl start owserver
  • systemctl status owserver
  1. MAke sure owpost.toml file matches owserver configuration

owlogger

For the cloud server store and display program

The install script will add the following files to /etc/systemd/system

Service (owlogger.service)

[Unit]
Description=OWLogger web server
After=network.target caddy.service
Requires=caddy.service

[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/local/lib/owlogger/owlogger.py 
WorkingDirectory=/usr/local/lib/owlogger
Restart=on-failure
User=www-data
Group=www-data

[Install]
WantedBy=multi-user.target

  1. set up caddy
  2. check owlogger.toml file
  3. start owlogger
  • systemctl enable owlogger
  • systemctl start owlogger
  • systemctl status owlogger
  1. Set up users if password protection is desired