Skip to content

Add healthcheck - #71

Merged
oschwartz10612 merged 7 commits into
fosrl:devfrom
woutervanelten:add-healthcheck
Jun 30, 2025
Merged

Add healthcheck#71
oschwartz10612 merged 7 commits into
fosrl:devfrom
woutervanelten:add-healthcheck

Conversation

@woutervanelten

Copy link
Copy Markdown
Contributor

Community Contribution License Agreement

By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.

Description

Expanded the code to write a /tmp/healthy file if ping is successfull.
Removes the /tmp/healthy file if ping failes 3 times.

How to test?

add the following to docker-compose to have healthcheck.

healthcheck:
  test: ["CMD-SHELL", "test -f /tmp/healthy"]
  interval: 30s
  timeout: 10s
  retries: 3

extended the ping check that creates a /tmp/healthy file if ping successfull and removes that file if ping failes 3 times.

With this you can add the following to the newt docker compose to do the health check:
healthcheck:
  test: ["CMD-SHELL", "test -f /tmp/healthy"]
  interval: 30s
  timeout: 10s
  retries: 3
added healthy check in main.go
extended the ping check that creates a /tmp/healthy file if ping successfull and removes that file if ping failes 3 times.

With this you can add the following to the newt docker compose to do the health check:
healthcheck:
  test: ["CMD-SHELL", "test -f /tmp/healthy"]
  interval: 30s
  timeout: 10s
  retries: 3
@woutervanelten

Copy link
Copy Markdown
Contributor Author

@oschwartz10612 , is this the correct way to suggest an improvement?

@oschwartz10612

Copy link
Copy Markdown
Member

Hi! Yes this is great thank you! I like the approach I think.

I would suggest though that we make the file location configurable with a CLI and ENV var so it is not hardcoded to write on to people's systems. I would make it opt in meaning that it should not write the file unless the cli arg is provided telling it where. I think in the current form it would also fail on Windows as there is no /tmp dir.

Added cli and env function
fixed some errors,
This file should be ok.
synced with dev
@woutervanelten

Copy link
Copy Markdown
Contributor Author

I added the suggested changes.
And also updated the code to sync with the .dev
@oschwartz10612 could you check, and if ok release it?

@oschwartz10612
oschwartz10612 merged commit 295cadc into fosrl:dev Jun 30, 2025
@oschwartz10612

Copy link
Copy Markdown
Member

Thanks!

@RomRider

Copy link
Copy Markdown

Could be great to update the documentation with this new feature. Thanks for implementing this!

@woutervanelten

woutervanelten commented Jul 11, 2025

Copy link
Copy Markdown
Contributor Author

Could be great to update the documentation with this new feature. Thanks for implementing this!

I did a pull request to pull the updated readme.
for those that can't wait ;)

add HEALT_FILE=*** to your env.
eg: HEALTH_FILE=/tmp/healthy

And add the following to the docker compose:

healthcheck:
  test: ["CMD-SHELL", "test -f /tmp/healthy"]
  interval: 30s
  timeout: 10s
  retries: 3
  start_period: 10s

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.

3 participants