Keep a daemon running on FreeBSD

What you're looking for is called a supervisor. I don't think FreeBSD comes with one out of the box. But there are some in the ports. I see at least;

  • supervisord is available as a port called py-supervisor (the port has several flavors, install with pkg install py37-supervisor or whatever matches your Python version).
  • daemontools is available as a port.
  • Monit is available as a port.
  • FSCD is available as a port called fsc.

I suggest supervisord. Install the package and add a stanza to /usr/local/etc/supervisord.conf:

[program:memcached]
command=/usr/local/etc/rc.d/memcached

To run supervisord at boot time, edit /etc/rc.conf or /etc/rc.conf.local to have the line

supervisord_enable="YES"

Whichever supervisor you choose, make sure to disable the direct starting of memcached.

Tags:

Freebsd