We recently had a similar need. We are running an Ubuntu 14.04 LTS server, so created an upstart
process to start the process at boot as and restarts if it exits for any reason.
It's worked out extremely well for us, including the automatic restart; our long-running process eventually looses the MySQL connection. The script handles the exception and exits, before the upstart
process automatically restarts the process. We have also added a cron
script to monitor the process, just in case there is a bigger error that upstart
gives up trying to restart; we have a fail-safe in the event a simple restart doesn't correct the prior error.