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.
If you do not already have an rc.d script for your process, you can fairly easily achieve the desired result with the daemon(8) command. The command will run a child process in the background, and with the command line option
-r, you can get it to restart the child process if it dies:
$ daemon -r /some/path/to/command
In later versions of FreeBSD, you can specify
-R <delay in seconds> to specify how long to wait before restarting the process.
To start the process after rebooting, specify the command in the crontab(5) file like this:
@reboot daemon -r /some/path/to/command
To edit the crontab file, use
$ crontab -e