Here is my summarized answer; Since what you are trying to do is monitor your application and take action in case of its failure, K8s probes are there to help you with this.
There are three types of k8s probes, readiness probes, liveness probes and stratup probes.
Liveness probe is used to to check if an app is alive. If a probe fails, container is restarted (probe assumes container is dead since liveness probe failed).
Readiness probes check if an app is ready to serve traffic. If readiness probe fails, pod is removed from a list of service endpoints (and no requests are sent to this pod until the readiness probe stops failing)
Startup probes are used to check if application started properly. All other probes are disabled if a startup probe is provided, until it succeeds.
Check the k8s docs for more information: configure-liveness-readiness-startup-probes