What's the idiomatic way? I'd prefer the most standard and yet simple way with fewer additional dependencies. Something like an alternative to systemd of Linux.
/etc/rc.conf (or relevant
rc.conf.d files) will start a service on boot.
For restarting on crashes, the canonical way to do it would involve daemontools.
You can add script to cron every (in example) two minutes:
#!/bin/sh process = 'my-secret-service' # process name if ps ax | grep -v grep | grep $process then echo "$process is alive." else echo "$process is dead, but will be launched." /usr/local/bin/my-secret-service #launch command fi