Daemons for a developer on Mac OS

How I solve the problem of maintaining long-running processes on my laptop

I am a developer and a linux system administrator who needs some daemons on my laptop, time to time. Managing these daemons, remembering their parameters and, most importantly remembering to run them is not an easy task. For all of these I decided to use supervisord.

To get supervisord, my suggestion is first to install python from homebrew and pip install supervisor.

Choose a folder for your supervisord (mine is ~/Can/supervisor/), create a conf.d and childlogs folder in it. For all files below, don’t forget to replace “/Users/canburak/” with your home path. Put the following in supervisor.conf:

[supervisord]
nodaemon=true
directory=%(here)s
childlogdir=childlogs
[unix_http_server]
file=supervisord.sock
[supervisorctl]
serverurl=unix://%(here)s/supervisord.sock
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[include]
files = conf.d/*.conf

Fill your conf.d folder with your daemons. An example daemon file conf.d/dovecot.conf is:

[program:dovecot]
command=/usr/local/sbin/dovecot ...
directory=/Users/canburak/Can/dovecot
autostart=true

Finally, you need the supervisord to start with the system. Put the following to /Library/LaunchDaemons/com.agendaless.supervisord.plist

Copy paste from the gist

Add this to launchd: sudo launchctl load -w /Library/LaunchDaemons/com.agendaless.supervisord.plist

From now an you can simply add an alias supervisorctl=“supervisorctl -c ~/Can/supervisor/supervisor.conf” to your ~/.bash_profile and command your daemons easily.