Streamlit healthcheck in docker-compose

Hi! I am trying to deploy streamlit app with docker-compose. But I ran into some difficulties. From time to time, my connection to the database is knocked out, and it can also give other errors. But streamlit continues to work and displays an error bar. I would like to implement a helcheck that catches any errors and restarts the container. However, GET /healthz always prints “ok”. How can I catch it?