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.serviceshows status of ufw (firewall) - Need to press Ctrl-C to exit
- e.g.
- start | stop
- e.g.
systemctl stop caddy.serviceto 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
- e.g.
- 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
- e.g.
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
- configure owserver
- start owserver
systemctl enable owserversystemctl start owserversystemctl status owserver
- 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
- set up caddy
- check owlogger.toml file
- start owlogger
systemctl enable owloggersystemctl start owloggersystemctl status owlogger
- Set up users if password protection is desired