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).

  1. Included with MQTTany is a .service file 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.service
    
  2. We 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=
    
  3. Next we need to tell systemd about our new file:

    sudo systemctl daemon-reload
    
  4. And lastly we enable our service to start on boot, and start it:

    sudo systemctl enable mqttany
    sudo systemctl start mqttany
    
  5. Verify that MQTTany started correctly by running:

    sudo systemctl status mqttany