Add healthcheck to the container - #1266
Open
wg1337 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In production environments (especially in Kubernetes with readinessProbe and livenessProbe) healthchecks are extremely useful. This PR adds a very simple healthcheck to the container that runs open.mp
The "healthcheck.py" is made to throw an error on every scenario I could think of. The idea is simple: constantly query the server and if the server returns bougus data, then consider the server as failed. Then it is up to the user if they want to restart it or not.
One interesting logic for the script is that I mark the server as failed if the gamemode is "Unknown". I believe this is going to be useful for most users since gamemode is set to "Unknown" when gamemode did not load properly, for example, the server is missing a plugin.
The variables can use environment variables in case some servers need special values, especially hostname's encoding. I ended up setting it to "cp1251" since it worked the best for most servers.
There is going to be a problem with containers that are built using "podman". They will get the following warning when building the container:
(docker builds (default) are not going to be affected and healthcheck will work properly without additional arguments)
But I intentionally did not change the "podman build" format to "docker" and rather want to rely on the user that they will know that they need to manually specify the healthcheck command as a podman command's argument. Similar situation is going to be to Kubernetes users, they need to specify readinessProbe/livenessProbe themselves.