In the composer.yaml file, we have the definition for the backend service. The healthcheck still needs to be implemented.
# todo: implement healthcheck
#healthcheck:
# test:
# [
# "CMD-SHELL",
# "cargo run healthcheck"
# ]
# interval: 10s
# retries: 5
# start_period: 10s
# timeout: 3s
For that reason, workflows take longer than they should. In the script to run E2E tests, we wait 20 seconds instead of waiting only until the container is healthy.
wait_for_container_to_be_healthy torrust-mysql-1 10 3
# todo: implement healthchecks for tracker and backend and wait until they are healthy
#wait_for_container torrust-tracker-1 10 3
#wait_for_container torrust-idx-back-1 10 3
sleep 20s
See: https://github.com/torrust/torrust-index-backend/blob/develop/docker/bin/run-e2e-tests.sh#L47-L51
Proposal 1
Add a new endpoint tho the API: GET /status that should return a 200 code is the app is ready to process requests. It could contains a json body with more verbose report like:
{
"status": "Ok",
"database": "Ok",
"tracker": "Ok"
}
When something is wrong could return something like:
{
"status": "Error",
"error": "Cannot connect to database",
}
We can define this later. For now we just check that return a 200 code.
The healthcheck could be something like
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3030/health"]
interval: 30s
timeout: 10s
retries: 3
Links
In the composer.yaml file, we have the definition for the backend service. The healthcheck still needs to be implemented.
For that reason, workflows take longer than they should. In the script to run E2E tests, we wait 20 seconds instead of waiting only until the container is healthy.
See: https://github.com/torrust/torrust-index-backend/blob/develop/docker/bin/run-e2e-tests.sh#L47-L51
Proposal 1
Add a new endpoint tho the API:
GET /statusthat should return a 200 code is the app is ready to process requests. It could contains a json body with more verbose report like:{ "status": "Ok", "database": "Ok", "tracker": "Ok" }When something is wrong could return something like:
{ "status": "Error", "error": "Cannot connect to database", }We can define this later. For now we just check that return a 200 code.
The healthcheck could be something like
Links
curloriwr