Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add curl on the Docker image #18462

Closed
wants to merge 3 commits into from
Closed

Conversation

rockyluke
Copy link

@rockyluke rockyluke commented Jul 30, 2023

Thanks for your amazing work!

Add curl to be able to manage health check with Docker.

$ docker ps
koenkk/zigbee2mqtt:1.32.1 "docker-entrypoint.s…" 3 hours ago Up 3 hours (healthy) zigbee2mqtt

This MR need to be squashed 🙏

Handle container status with basic healthcheck
@sjorge
Copy link
Contributor

sjorge commented Jul 31, 2023

The frontend is optional, so this will fail for people that chose not to enable the frontend.

@rockyluke
Copy link
Author

My bad !

Could keeping curl embed be an acceptable solution for you ? It will allow people using docker and docker compose to get the status easily ?

    healthcheck:
      test: [ "CMD", "curl", "http://127.0.0.1:8080/#/" ]
      interval: 1m
      timeout: 10s
      retries: 3
      start_period: 60s

@rockyluke rockyluke changed the title feat: add health check in Dockerfile feat: add curl on the Docker image Jul 31, 2023
@rockyluke
Copy link
Author

Commit and description updated 🚀

@Koenkk
Copy link
Owner

Koenkk commented Jul 31, 2023

@sjorge while the frontend is indeed optional, I don't see a better way to do a healthcheck

@sjorge
Copy link
Contributor

sjorge commented Jul 31, 2023

@sjorge while the frontend is indeed optional, I don't see a better way to do a healthcheck

Is there an easy way to see if it’s enabled? And then pick the curl check or /bin/true otherwise?

@Koenkk
Copy link
Owner

Koenkk commented Jul 31, 2023

@sjorge this config is not done from the z2m side but in the docker-compose.yml (so user has to make sure frontend is enabled when deciding to add this healthcheck)

@skarcha
Copy link

skarcha commented Aug 4, 2023

Maybe a solution could be using a MQTT message. Ask zigbee2mqtt for its status using a MQTT message an read its response using another topic.

@alex3305
Copy link

alex3305 commented Sep 1, 2023

Why don't you just use wget? That's already available by default on alpine. That healthcheck would be something like:

    healthcheck:
      test: [ "CMD", "wget", "-O-", "http://127.0.0.1:8080/#/" ]
      interval: 1m
      timeout: 10s
      retries: 3
      start_period: 60s

Or just check if the process is running with pgrep:

    healthcheck:
      test: [ "CMD", "pgrep", "node" ]
      interval: 1m
      timeout: 10s
      retries: 3
      start_period: 60s

Both solutions are untested, but should theoretically work.

@Koenkk
Copy link
Owner

Koenkk commented Sep 3, 2023

@alex3305 wget seems to be available indeed so curl is not needed.

ubuntu@j3455:~$ docker exec -it zigbee2mqtt /bin/sh
/app # wget
BusyBox v1.36.1 (2023-07-27 17:12:24 UTC) multi-call binary.

Usage: wget [-cqS] [--spider] [-O FILE] [-o LOGFILE] [--header STR]
	[--post-data STR | --post-file FILE] [-Y on/off]
	[-P DIR] [-U AGENT] [-T SEC] URL...

@Koenkk Koenkk closed this Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants