tiny-pilot / tinypilot

Use your Raspberry Pi as a browser-based KVM.
https://tinypilotkvm.com
MIT License
2.99k stars 250 forks source link

Override Janus systemd config #1622

Closed jdeanwallace closed 11 months ago

jdeanwallace commented 11 months ago

Resolves https://github.com/tiny-pilot/tinypilot/issues/1578

This PR overrides the default Janus systemd config in order set additional systemd settings. Specifically:

 [Unit]
 Description=Janus WebRTC gateway
 After=network.target
 Documentation=https://janus.conf.meetecho.com/docs/index.html
+# Give up if we restart on failure 20 times within 5 minutes (300 seconds).
+StartLimitIntervalSec=300
+StartLimitBurst=20

 [Service]
 Type=forking
 ExecStart=/usr/bin/janus --disable-colors --daemon --log-stdout
 Restart=on-failure
+RestartSec=1
 LimitNOFILE=65536

 [Install]
 WantedBy=multi-user.target

Janus with STUN requires the network to be online, otherwise janus fails to start. Theses additional settings are needed to allow Janus with STUN settings a better chance of starting up successfully, by giving it more chances to restart on failure. Seeing as STUN is an optional setting, we didn't want Janus to always require an online network because it might unnecessarily delay TinyPilot's H.264 video stream.

Testing

To enable STUN, append the following block to /etc/janus/janus.jcfg:

nat: {
  stun_server = "stun.gmx.de"
  stun_port = 3478
}

Now if you restart your device, the janus service should start successfully on boot. On my device janus restarted 8 times in 12 seconds before successfully running.

Review on CodeApprove

jdeanwallace commented 11 months ago
Automated comment from CodeApprove ➜

⏳ @jotaen4tinypilot please review this Pull Request