Open Babalion opened 1 year ago
Hi, do you have an example how this would look like? Sorry, never did this before
Of course!
In a common matrix-synapse docker-compose.yml
one can add the following healthcheck:
healthcheck:
test: ["CMD", "curl", "-fSs", "http://localhost:8008/health"]
interval: 15s
timeout: 5s
retries: 3
start_period: 5s
The command specified after test
will be executed by the docker-daemon in the given interval.
After specified retries or timeout the docker-daemon will mark the service as unhealthy.
It is now up to the server administrator how to proceed with unhealthy services (for example send a notification, restart the container etc.).
So the question is, what command could be executed regularly in the bot container that succeeds when everything is fine and fails when something has gone wrong?
Sounds good & sensible. Sadly with the framework that we use does not allow to easily implement a /health
. I will try to think of something
We don't need a site like the /health
in matrix-synapse.
Any shell command is fine. We can for example curl for a variable in a json response.
I've also seen healthchecks where they simply ping an arbitrary URL of the service.
So what would you check first, to be sure everything is fine?
Maybe the source code does not need to be changed at all... What I noticed was, that the bot sometimes does not respond to a message. I had to restart the container then. Maybe this is something one could check in a healthcheck?
Sorry for the late response. I was thinking about this a lot and I think there is no easy way to check the status/health of the bot. The easiest I could think of, was to check the presence status of the bot like this
curl -H 'Authorization: Bearer syt_access_token_of_the_bot_itself' https://synapse.hyteck.de/_matrix/client/v3/presence/@test-registration-bot:hyteck.de/status
whicht returns either {"presence":"online","last_active_ago":1957,"currently_active":true}
or {"presence":"offline","last_active_ago":52746674}
Sorry for the late response. I was thinking about this a lot and I think there is no easy way to check the status/health of the bot. The easiest I could think of, was to check the presence status of the bot like this
curl -H 'Authorization: Bearer syt_access_token_of_the_bot_itself' https://synapse.hyteck.de/_matrix/client/v3/presence/@test-registration-bot:hyteck.de/status
whicht returns either
{"presence":"online","last_active_ago":1957,"currently_active":true}
or{"presence":"offline","last_active_ago":52746674}
That works too imo
I suggest adding a health check to the
docker-compose.yml
file. I can create a pull request for this, but I am unsure which would be the best way to check if the service is still healthy.I am grateful for any help!