Run as a Service
Start pi-webrtc when the device boots, and restart it if it stops. This page uses systemd.
1. Run PulseAudio as a system service
Skip this step if you use --no-audio. A service has no user session, so PulseAudio must run for the whole system (reference).
-
Install it:
sudo apt install pulseaudio -
Create
/etc/systemd/system/pulseaudio.service:[Unit] Description=PulseAudio Daemon After=rtkit-daemon.service systemd-udevd.service dbus.service [Service] Type=simple ExecStart=/usr/bin/pulseaudio --system --disallow-exit --disallow-module-loading Restart=always RestartSec=10 [Install] WantedBy=multi-user.target -
Stop clients from starting their own PulseAudio:
echo 'autospawn = no' | sudo tee -a /etc/pulse/client.conf > /dev/null -
Give access, enable the service, and reboot:
sudo adduser root pulse-access sudo systemctl enable pulseaudio.service sudo reboot
2. Run pi-webrtc at boot
-
Create
/etc/systemd/system/pi-webrtc.service. ChangeWorkingDirectoryandExecStartto your own path and options:[Unit] Description=pi-webrtc camera stream After=network-online.target pulseaudio.service [Service] Type=simple WorkingDirectory=/path/to ExecStart=/path/to/pi-webrtc --config=/path/to/config.yml Restart=always RestartSec=10 [Install] WantedBy=multi-user.targetA config file keeps
ExecStartshort. You can also put all the options on theExecStartline. -
Enable and start it:
sudo systemctl daemon-reload sudo systemctl enable pi-webrtc.service sudo systemctl start pi-webrtc.service -
Check that it runs, and read its log:
systemctl status pi-webrtc.service journalctl -u pi-webrtc.service -f
Restart=always also helps with RTSP input: pi-webrtc exits when the RTSP stream changes its size or codec, and systemd starts it again.

