I’ve written a script that monitors a particular app, ensuring that it keeps running, even if it’s frozen or has crashed.
I have posted it on the StackOverflow site: https://stackoverflow.com/a/67772583/43615
Let me know if you have any improvement suggestions.