Search code examples
pythongpiomessagebrokeriothivemq

HiveMQ and IoT control


I recently installed HiveMQ on a Ubuntu machine and everything works fine. Being new to Linux( I am more on windows guy) , I am stuck with following question.

  1. I started HiveMQ with command as ./bin/run.sh . A window opens and confirm that HiveMQ is running..Great !!!. I started this with putty and when I close the putty , HiveMQ also stops. How to make HiveMQ run all the time ?.

  2. I am using the HiveMQ for my IoT projects ( raspberry pi). I know to subscribe and publish to HiveMQ broker from python , but what confuses me is , should I be running the python program continuously to make this work ?. Assuming I need to trigger 2+ GPIO on Pi , can I write one program and keep it running by making it subscribe to 2+ topic for trigger events ?.

Any help is greatly appreciated.

Thanks


Solution

  • In order to start HiveMQ in the background, you can install it as a service. The details are covered in the documentation here. If you have a debian based system, execute the following commands:

    cp /opt/hivemq/bin/init-script/hivemq-debian /etc/init.d/hivemq
    chmod +x /etc/init.d/hivemq
    

    For other Linux Systems the following should do it:

    cp /opt/hivemq/bin/init-script/hivemq /etc/init.d/hivemq
    chmod +x /etc/init.d/hivemq
    

    Now you can start HiveMQ in the background with /etc/init.d/hivemq start.