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

Docker HEALTHCHECK #43

Open
kappsegla opened this issue Feb 2, 2022 · 2 comments
Open

Docker HEALTHCHECK #43

kappsegla opened this issue Feb 2, 2022 · 2 comments
Assignees

Comments

@kappsegla
Copy link
Contributor

kappsegla commented Feb 2, 2022

When running a docker container sometimes it's hard for docker to know the status of the program(s) running inside the the container. To help docker know if everything is running as intended we can use something called health check.

https://scoutapm.com/blog/how-to-use-docker-healthcheck

If we add the following to our Dockerfile:

HEALTHCHECK CMD curl --fail http://localhost:8080 || exit 1

By adding a HEALTHCHECK line to our Dockerfile we can periodically try to connect to our server and if it returns 200 OK everything is fine but if it returns an error too many times in a row the container will be marked as unhealthy.

To make the system better we can add an url to our server like http://localhost:8080/status which can be queried and return the status of the server as a simple 200 OK or some other error message when the server isn't running as intended.

@Ahsanadam
Copy link
Contributor

How can we implement an url to our server like http://localhost:8080/status, in order for it to function?

@kappsegla
Copy link
Contributor Author

How can we implement an url to our server like http://localhost:8080/status, in order for it to function?

When a request comes in to the server an instance of ClientHandler will be created and its run method will be called in a thread.
When reading information from the incoming request there will be a path in the first line containing /status.
Using the HttpParser class in our project we can get help obtaining this information.
It's then a matter of running different code depending on what path is in the request.

@Ahsanadam Ahsanadam self-assigned this Feb 9, 2022
@Vimbayinashe Vimbayinashe linked a pull request Feb 10, 2022 that will close this issue
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 a pull request may close this issue.

2 participants