Comments (10)
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.
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.
That would be a great addition. Feel free to contribute ;-)
from docker-mosquitto.
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.
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.
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.
@neurove - your post started me thinking. What do you think about IOTstack issue 415 as an expansion on your idea?
from docker-mosquitto.
@neurove I tried your healthcheck but getting this error:
Unable to connect (Lookup error.).
from docker-mosquitto.
@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.
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)
- Mosquitto logging permissions HOT 8
- Fix duplicate logging statement in default mosquitto config
- Support for docker on rasberry pi HOT 2
- [Question] Set username and password for brokerconnection HOT 3
- Provide an example how to "migrate" to eclipse-mosquitto
- adduser in Dockerfile recommendation.
- Memory leak HOT 2
- Sonoff couldn't connect to MQTT HOT 2
- Bug when docker build is executed. HOT 1
- Not able to ping containers within the same network.
- Removing dependency on Q? HOT 2
- Failure to write to folder when loaded using 'run' instructions. HOT 1
- Add Client tools HOT 2
- Consider adding the Mosquitto repo key to the build context HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker-mosquitto.