Stopping supervisord: Shut down

supervisorctl
supervisord environment variables
supervisor directory
supervisord delay start
supervisor run as user
supervisord include files
supervisor timeout
supervisord log

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

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

Running Supervisor, I am trying to use supervisord to manage instances of playframework applications​. The framework supplies commands for starting and stopping  systemd starts the shutdown process and tries to stop supervisord; This triggerd drain-connections to be stopped where we have the commands we want to be executed; The above commands will take the instance out of the pool and sleep for an arbitrary period of time; drain-connections finishes “stopping” systemd stops supervisord; shutdown proceeds

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).

Allow a custom "stop-command" to manage graceful shutdown of , You should check out the following configuration options: stopsignal to specify which signal gets sent to your program in order to tell it to stop gracefully. supervisord will stop all processes, reload the configuration from the first config file it finds, and start all processes. SIGUSR2 supervisord will close and reopen the main activity log and all child log files.

Try running these commands

sudo unlink /run/supervisor.sock

and

sudo /etc/init.d/supervisor start

Is supervisord shutting down gracefully?, To stop an app during the time another one when app1 is running, app2 is shut down. It is important that this process exits gracefully (not killed). I use supervisord and ubuntu server to run it. When the server get ACPI shutdown signal (reboot command from a VPS provider, that's what EC2 does I assume), will supervisord (and the whole system) wait for all the child processes to exit during shutdown sequence?

$ 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

Supervisor with Docker: Lessons learned, It stops, and re-starts all managed applications. supervisorctl restart <name>. Restart application without making configuration changes available. This is probably not the recommended way of shutting down supervisor but the following configuration has worked well for me. [program:something] command = bash -c " something && kill -s SIGINT `cat supervisord.pid` " stopasgroup = true ; other bits

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.

Supervisord: Restarting and Reloading – Onur Güzel, SIGINT supervisord and all its subprocesses will shut down. SIGHUP supervisord will stop all processes, reload the configuration from the first config file it  Also, some applications start one process, spawn another, and drop privileges. Sending a kill signal to the one started by supervisord doesn't do anything useful. A shining example is mysqld_safe on Alpine Linux, which is easily stopped using mysqladmin shutdown, but not supervisorctl stop mysqld.

supervisord - supervisord Documentation, supervisord and all its subprocesses will shut down. This may take several seconds. SIGHUP. supervisord will stop all processes, reload the configuration from  The relative priority of the program in the start and shutdown ordering. Lower priorities indicate programs that start first and shut down last at startup and when aggregate commands are used in various clients (e.g. “start all”/”stop all”). Higher priorities indicate programs that start last and shut down first. Default: 999. Required: No.

supervisor(1) — supervisor — Debian testing, Choices: present; started; stopped; restarted; absent; signalled. The desired state of program/group. supervisorctl_path. -. path to supervisorctl executable. The claim: The US Postal Service will shut down by June and be replaced by corporate partnerships.

supervisorctl – Manage the state of a program or group of programs , I have tried using "supervisorctl -c shutdown [all]" and this shuts down the daemon and in the supervisorctl interactive console it says nginx is stopped. However  Windows 10: Microsoft unmasks the mysterious 'G' app that stops you shutting down. Don't worry about that strange 'G' app that's preventing you from shutting down Windows 10, explains Microsoft.

Comments
  • 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.
  • @MartijnPieters I search the file with sudo find / -iname 'supervisord.conf' and only found this /etc/supervisord.conf.
  • 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?
  • What was wrong? Perhaps you can add an answer below if you think it could help future visitors?
  • Oh, and there are ready-made init scripts available for supervisord to save you the hassle of writing your own.
  • unlink: cannot unlink '/tmp/supervisor.sock': No such file or directory
  • find / -name supervisor.sock It may sit here too. ./var/run/supervisor.sock
  • @Richard From your supervisord.conf file, It is supposed to be in /tmp/supervisor.sock
  • this didn't solve the problem, it's not making any sense we have to unlink to stop the supervisor.
  • 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?
  • I learned that killing the demon should only be the very last resort, I suggest to consider using sudo systemctl stop supervisor instead.
  • I'm on centos7. supervisorctl pid return the pid, but $(supervisorctl pid) display command not found.
  • 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.