Giter Site home page Giter Site logo

Add in a health check about docker-mosquitto HOT 10 OPEN

toke avatar toke commented on June 27, 2024
Add in a health check

from docker-mosquitto.

Comments (10)

magnus919 avatar magnus919 commented on June 27, 2024 1

Sorry to poke an ancient issue, but I found this while googling to see if there were any plans to add a healthcheck to this image. Is this still sort of out there on the long-term wishlist?

from docker-mosquitto.

neurove avatar neurove commented on June 27, 2024 1

I added this healthcheck for the mosquitto docker container on my docker-compose.yaml

healthcheck:
test: ["CMD-SHELL", "mosquitto_sub -h $MQTT_HOST -p $MQTT_POST -t '#' -u $MQTT_USER -P $MQTT_PASSWORD -C 1 | grep -v Error || exit 1"]
interval: 10s
timeout: 5s
retries: 5

from docker-mosquitto.

toke avatar toke commented on June 27, 2024

That would be a great addition. Feel free to contribute ;-)

from docker-mosquitto.

rossdargan avatar rossdargan commented on June 27, 2024

Ok, had a quick look. This won't be possible without including the client tools which I see you were not massively keen on: #8

So, two options, either this is a good enough reason to include the client tools, or I create a second DockerFile for a healthcheck version of this container.

Also need to find a way to pass through credentials to the healthcheck since I have mine protected via the config! Not sure how easy thats going to be!

from docker-mosquitto.

toke avatar toke commented on June 27, 2024

No problem. I just had no reasons for the client tools but if there is a reason I think it's correct to include them. So #8 and #10 are related and #8 can be closed then too.

from docker-mosquitto.

rossdargan avatar rossdargan commented on June 27, 2024

Just an update - close, but not quite reliable yet (it actually totally crashes docker somehow if the password isn't correct!)

https://stackoverflow.com/questions/39275666/script-to-check-mosquitto-is-healthy

from docker-mosquitto.

Paraphraser avatar Paraphraser commented on June 27, 2024

@neurove - your post started me thinking. What do you think about IOTstack issue 415 as an expansion on your idea?

from docker-mosquitto.

genieai-vikas avatar genieai-vikas commented on June 27, 2024

@neurove I tried your healthcheck but getting this error:
Unable to connect (Lookup error.).

from docker-mosquitto.

Paraphraser avatar Paraphraser commented on June 27, 2024

@genieai-vikas maybe take a look at SensorsIot/IOTstack and, in particular iotstack_healthcheck.sh.

The IOTstack solution started with the basic idea from @neurove but grew. It has been "in production" with IOTstack for the last month and no issues have come in yet (touch wood).

There is also some documentation that may prove useful.

from docker-mosquitto.

neurove avatar neurove commented on June 27, 2024

For documentation purposes, I changed the healthcheck to:

healthcheck:
test: ["CMD-SHELL", "mosquitto_sub -h $MQTT_HOST -p $MQTT_POST -t '#' -u $MQTT_USER -P $MQTT_PASSWORD -E -i healthcheck | grep -v Error || exit 1"]
nterval: 10s
timeout: 5s
retries: 5

using -E instead of -C 1 exits immediately after subscribing instead of waiting for a message being published

from docker-mosquitto.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.