"Even things that can't go wrong, do." - Troubleshooting Analog Circuits, Robert "Bob" Pease.
I had an application on a Raspberry PI that paired with a Bluetooth Low Energy device to fetch and send its data through a 3G dongle, on the premises of non-technical people who cannot troubleshoot, in different countries and time zones. There were a lot of things that could go wrong, and I wrote code to mitigate and recover, including pulling new code.
Part of it was using the Actor Model. I wrote actors to connect to the device, pulling data, sending data, computing what was sent, etc. The actor system handled the actors, when one died, it would recreate another one when an unhandled exception was met, for example.
https://en.wikipedia.org/wiki/Actor_model
If you're doing Scala, take a look at Akka. The new Scala has native support for this, if I remember correctly, without Akka.
If you're doing Python: https://github.com/kquick/Thespian, https://thespianpy.com/doc/
You could also use Supervisor: http://supervisord.org. It's a client/server system for process control. You can have it start at boot time, you can add event listeners and trigger actions.