Start on boot
Linux
On most Linux distributions (including Ubuntu and Debian, but not OpenWrt), systemd is in charge of managing services and starting them on boot.
Move the server executable and configuration in global folders:
sudo mv mediamtx /usr/local/bin/
sudo mv mediamtx.yml /usr/local/etc/Create a systemd service:
sudo tee /etc/systemd/system/mediamtx.service >/dev/null << EOF
[Unit]
Wants=network.target
[Service]
ExecStart=/usr/local/bin/mediamtx /usr/local/etc/mediamtx.yml
[Install]
WantedBy=multi-user.target
EOFIf SELinux is enabled (for instance in case of RedHat, Rocky, CentOS++), add correct security context:
semanage fcontext -a -t bin_t /usr/local/bin/mediamtx
restorecon -Fv /usr/local/bin/mediamtxEnable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable mediamtx
sudo systemctl start mediamtxOpenWrt
Move the server executable and configuration in global folders:
mv mediamtx /usr/bin/
mkdir -p /usr/etc && mv mediamtx.yml /usr/etc/Create a procd service:
tee /etc/init.d/mediamtx >/dev/null << EOF
#!/bin/sh /etc/rc.common
USE_PROCD=1
START=95
STOP=01
start_service() {
procd_open_instance
procd_set_param command /usr/bin/mediamtx
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
EOFEnable and start the service:
chmod +x /etc/init.d/mediamtx
/etc/init.d/mediamtx enable
/etc/init.d/mediamtx startRead the server logs:
logreadWindows
Download the WinSW v2 executable and place it into the same folder of mediamtx.exe.
In the same folder, create a file named WinSW-x64.xml with this content:
<service>
<id>mediamtx</id>
<name>mediamtx</name>
<description></description>
<executable>%BASE%/mediamtx.exe</executable>
</service>Open a terminal, navigate to the folder and run:
WinSW-x64 installThe server is now installed as a system service and will start at boot time.