Launching
The simplest way to launch MQTTany is from the command line:
cd /opt/mqttany
python3 mqttany/mqttany.py
But this has some obvious drawbacks: You have to run it manually, and must keep the terminal session open.
Most of the time you will want MQTTany to run in the background at startup. The following instructions will guide you through setting that up on Debian Linux (including Raspbian).
Included with MQTTany is a
.servicefile that tells systemd what it is and how to run it. We need to put that file in the right place:cd /opt/mqttany sudo cp mqttany.service /etc/systemd/system/mqttany.serviceWe need to specify the user that MQTTany should run as. Edit the file:
sudo nano /etc/systemd/system/mqttany.service
and add the username and group that MQTTany should run as:
User= Group=
Next we need to tell
systemdabout our new file:sudo systemctl daemon-reload
And lastly we enable our service to start on boot, and start it:
sudo systemctl enable mqttany sudo systemctl start mqttanyVerify that MQTTany started correctly by running:
sudo systemctl status mqttany