Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anhphamt/dd6e12a4fba60eb6d711df2e06a6677e to your computer and use it in GitHub Desktop.
Save anhphamt/dd6e12a4fba60eb6d711df2e06a6677e to your computer and use it in GitHub Desktop.
Setting up supervisord in Mac OSX or CENTOS

If you do not install pip, you can try this link: http://sharadchhetri.com/2014/05/30/install-pip-centos-rhel-ubuntu-debian/

  1. install: easy_install supervisor
  2. configure:
    1. mkdir -p /etc/supervisord/conf.d
    2. echo_supervisord_conf > /etc/supervisord/supervisord.conf
    3. echo "files = conf.d/*.conf" >> /etc/supervisord/supervisord.conf

Create a new file /etc/rc.d/init.d/supervisord. Content is below.

https://gist.githubusercontent.com/fossilet/a729e9cf781f209f7cd024998d025b52/raw/6f14af75b703277cc8db055c3e2df248b9b392be/supervisord

Then you can run:

service supervisord start
service supervisord stop
service supervisord status

In the service please remember to add the command

prog_bin="${exec_prefix}/bin/supervisord -c /etc/supervisord/supervisord.conf"

If you have problem with port listening, try below solution:

sudo unlink /tmp/supervisor.sock
sudo unlink /var/run/supervisor.sock

To check status of supervisord

supervisorctl

Installation

Installing Supervisor on OS X is simple:

sudo pip install supervisor

This assumes you have pip. If you don't:

curl -O http://python-distribute.org/distribute_setup.py
python distribute_setup.py
sudo easy_install pip
sudo pip install supervisor
supervisord -c /usr/local/share/supervisor/supervisord.conf

Seeing all child processes running

supervisorctl -c /usr/local/share/supervisor/supervisord.conf

I find it helpful to create an alias in my bash profile for those 2 commands above so that I don't have to manually type -c all the time

echo "alias supervisord='supervisord -c /usr/local/share/supervisor/supervisord.conf'" >> ~/.bash_profile
echo "alias supervisorctl='supervisorctl -c /usr/local/share/supervisor/supervisord.conf'" >> ~/.bash_profile

To run supervisord at start up, we can use a plist file and load with launchctl

launchctl load /Library/LaunchDaemons/com.agendaless.supervisord.plist
launchctl unload /Library/LaunchDaemons/com.agendaless.supervisord.plist

Use the file launchfile.xml in below.

<!-- /Library/LaunchDaemons/com.agendaless.supervisord.plist -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>com.agendaless.supervisord</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/supervisord</string>
<string>-n</string>
<string>-c</string>
<string>/usr/local/share/supervisor/supervisord.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
[unix_http_server]
file=/usr/local/share/tmp/supervisor.sock
chmod=0700
[supervisord]
logfile = /usr/local/var/log/supervisord.log
logfile_maxbytes = 50MB
logfile_backups=10
loglevel = info
pidfile = /tmp/supervisord.pid
nodaemon = False
minfds = 1024
minprocs = 200
umask = 022
identifier = supervisor
directory = /usr/local/share/tmp
nocleanup = true
childlogdir = /usr/local/share/tmp
[supervisorctl]
serverurl = unix:///usr/local/share/tmp/supervisor.sock
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[include]
files = /usr/local/share/supervisor/conf.d/*.conf
@eboye
Copy link

eboye commented Jan 31, 2018

Hmm, I'm having issues seting it up on OSX, little help? This is what I have when running supervisorctl (alias):

http://localhost:9001 refused connection
supervisor>

@JannickBlmndl
Copy link

JannickBlmndl commented Jan 8, 2021

@eboye I had the same problem.

Commenting this part in the supervisord.conf
;[unix_http_server]
;file=/usr/local/var/run/supervisor.sock ; the path to the socket file

And adding this part to the config. Helped for me.
[inet_http_server] ; inet (TCP) server disabled by default
port=127.0.0.1:9001 ; ip_address:port specifier, *:port for all iface

Thanks to this stackoverflow thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment