In FreeBSD:
/usr/sbin/daemon -R 2 \ # If terminated, restart after two seconds
-u foouser \
-p /var/run/foo.pid \
-o /var/log/foo.error.log \
/usr/local/bin/foocmd
https://github.com/uxtely/ops-utils/blob/main/location-serve...