55

I tired to start supervisor but getting error. Can anyone help? Thanks

/etc/init.d/supervisord file.

SUPERVISORD=/usr/local/bin/supervisord
SUPERVISORCTL=/usr/local/bin/supervisorctl
case $1 in
start)
        echo -n "Starting supervisord: "
        $SUPERVISORD
        echo
        ;;
stop)
        echo -n "Stopping supervisord: "
        $SUPERVISORCTL shutdown
        echo
        ;;
restart)
        echo -n "Stopping supervisord: "
        $SUPERVISORCTL shutdown
        echo
        echo -n "Starting supervisord: "
        $SUPERVISORD
        echo
        ;;
esac

Then run these

sudo chmod +x /etc/init.d/supervisord
sudo update-rc.d supervisord defaults
sudo /etc/init.d/supervisord start

And getting this:

Stopping supervisord: Shut down

Starting supervisord: /usr/local/lib/python2.7/dist-packages/supervisor/options.py:286: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
  'Supervisord is running as root and it is searching '
Error: Another program is already listening on a port that one of our HTTP servers is configured to use.  Shut this program down first before starting supervisord.
For help, use /usr/local/bin/supervisord -h

Conf file (located at /etc/supervisord.conf):

[unix_http_server]
file=/tmp/supervisor.sock; (the path to the socket file)

[supervisord]
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10          ; (num of main logfile rotation backups;default 10)
loglevel=info               ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false              ; (start in foreground if true;default false)
minfds=1024                 ; (min. avail startup file descriptors;default 1024)
minprocs=200                ; (min. avail process descriptors;default 200)

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock; use a unix:// URL  for a unix socket

[program:myproject]
command=/home/richard/envs/myproject_stage/bin/python /home/richard/webapps/myproject/manage.py run_gunicorn -b 127.0.0.1:8002 --log-file=/tmp/myproject_stage_gunicorn.log
directory=/home/richard/webapps/myproject/
user=www-data
autostart=true
autorestart=true
stdout_logfile=/tmp/myproject_stage_supervisord.log
redirect_stderr=true
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Shah
  • 649
  • 1
  • 5
  • 11
  • Are you 100% certain there are no other `supervisord.conf` files around? As the warning states, it'll look in the current directory too, and in the local (relative to the current directory) `etc/` path, as well as relative to the `supervisord` executable. Use `-c` to be certain what configuration file is used. – Martijn Pieters Jan 23 '13 at 16:12
  • @MartijnPieters I search the file with `sudo find / -iname 'supervisord.conf'` and only found this `/etc/supervisord.conf`. – Shah Jan 23 '13 at 16:34
  • 1
    Good, that's that option eliminated; you still really want to use `-c` to prevent a local `supervisord.conf` from being picked up. Does your `supervisord` config work when started by hand? – Martijn Pieters Jan 23 '13 at 16:36
  • What was wrong? Perhaps you can add an answer below if you think it could help future visitors? – Martijn Pieters Jan 24 '13 at 08:09
  • @MartijnPieters Sorry what do you mean started by hand? – Shah Jan 24 '13 at 08:20
  • @MartijnPieters I enter my mistake. Its not solved yet. – Shah Jan 24 '13 at 08:21
  • I meant run `supervisord -c /etc/supervisor.conf` from the command line, what happens then? – Martijn Pieters Jan 24 '13 at 09:24
  • 2
    Oh, and there are [ready-made init scripts](https://github.com/Supervisor/initscripts) available for `supervisord` to save you the hassle of writing your own. – Martijn Pieters Jan 24 '13 at 09:25

7 Answers7

73

first of all, type this on your console or terminal

ps -ef | grep supervisord

You will get some pid of supervisord just like these

root 2641 12938 0 04:52 pts/1 00:00:00 grep --color=auto supervisord

root 29646 1 0 04:45 ? 00:00:00 /usr/bin/python /usr/local/bin/supervisord

if you get output like that, your pid is the second one. then if you want to shut down your supervisord you can do this

kill -s SIGTERM 29646

hope it helpful. ref: http://supervisord.org/running.html#signals

Community
  • 1
  • 1
48
sudo unlink /tmp/supervisor.sock

This .sock file is defined in /etc/supervisord.conf's [unix_http_server]'s file config value (default is /tmp/supervisor.sock).

sr01853
  • 6,043
  • 1
  • 19
  • 39
  • 2
    `unlink: cannot unlink '/tmp/supervisor.sock': No such file or directory` – Shah Jan 23 '13 at 12:55
  • 1
    find / -name supervisor.sock It may sit here too. ./var/run/supervisor.sock – sr01853 Jan 23 '13 at 13:01
  • 2
    @Richard From your supervisord.conf file, It is supposed to be in /tmp/supervisor.sock – sr01853 Jan 23 '13 at 13:03
  • 8
    this didn't solve the problem, it's not making any sense we have to unlink to stop the supervisor. – Colin Su Sep 18 '13 at 09:26
  • Any ideas what the root cause is here? I only recently started noticing this when restarting supervisord from running chef-client. Sure, removing this socket might allow supervisord to restart, but why was it left in place to begin with? –  Sep 24 '13 at 23:56
  • Why doesn't supervisor terminate with an error code to allow scripts to unlink automatically and retry? – Tal Weiss Dec 16 '13 at 09:58
20
$ ps aux | grep supervisor
alexamil         54253   0.0  0.0  2506960   6440   ??  Ss   10:09PM   0:00.26 /usr/bin/python /usr/local/bin/supervisord -c supervisord.conf

so we can use:

$ pkill -f supervisord  # kill it
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
  • 2
    I learned that killing the demon should only be the very last resort, I suggest to consider using `sudo systemctl stop supervisor` instead. – B--rian Mar 02 '19 at 22:07
18

This is what works for me. Run the following in the Terminal (For Linux machines)

To check if the process is running:

sudo systemctl status supervisor

To stop the process:

sudo systemctl stop supervisor
Prometheus
  • 1,148
  • 14
  • 21
16

Try running these commands

sudo unlink /run/supervisor.sock

and

sudo /etc/init.d/supervisor start
Chillar Anand
  • 27,936
  • 9
  • 119
  • 136
Viney
  • 171
  • 1
  • 4
6

As of version 3.0a11, you could do this one-liner:

sudo kill -s SIGTERM $(sudo supervisorctl pid) which hops on the back of the supervisorctl pid function.

Jonathan
  • 10,936
  • 8
  • 64
  • 79
  • I'm on centos7. `supervisorctl pid` return the pid, but `$(supervisorctl pid)` display `command not found`. – Cloud Mar 03 '17 at 07:15
  • Have you tried something like `\`supervisorctl pid\`` instead? `$()` is just a way of returning the output of another command within the same command line. I'm not sure if Centos7 would have this, but I'd be scratching my head if it didn't. In any case if you can't do my one-liner above, just separate it out to two commands instead. – Jonathan May 24 '17 at 18:28
3

          There are many answers already available. I shall present a cleaner way to shut down supervisord.

          supervisord by default, creates a file named supervisord.pid in the directory where supervisord.conf file exists. That file consists the pid of the supervisord daemon. Read the pid from the file and kill the supervisord process.

          However, you can configure where the supervisord.pid file should be created. Refer this link to configure it, http://supervisord.org/configuration.html

yottabytt
  • 2,280
  • 1
  • 18
  • 14