Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending general signal to child process of supervisord

Tags:

supervisord

I am using supervisord to manage a bunch of processes. Is it possible to use supervisorctl to send arbitrary signals to these processes without actually stopping them and setting stopsignal?

like image 358
user1578214 Avatar asked Nov 29 '12 18:11

user1578214


People also ask

How do I start a Supervisord process?

To start supervisord, run $BINDIR/supervisord. The resulting process will daemonize itself and detach from the terminal. It keeps an operations log at $CWD/supervisor. log by default.

What is the purpose of Supervisord?

Supervisord or Supervisor daemon is an open source process management system. In a nutshell: if a process crashes for any reason, Supervisor restarts it. From the Supervisord website: Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.

How can the supervisor process be stopped?

Finally, you can exit supervisorctl with Ctrl+C or by entering quit into the prompt: supervisor> quit.

What user does Supervisord run as?

To be able to run any subprocess as a different user from what supervisord is running as, you must run supervisord as root. It tells you if you run multiple subprocesses, you have to run as a root to be able to start all the subprocesses, meaning that if you have more than 2 projects in you supervisord.


2 Answers

Until 3.2.0 (released November 2015), supervisorctl had no support for sending arbitrary signals to the processes it manages.

From 3.2.0 onwards, use supervisorctl signal:

signal <signal name> <name>     Signal a process
signal <signal name> <gname>:*      Signal all processes in a group
signal <signal name> <name> <name>  Signal multiple processes or groups
signal <signal name> all        Signal all processes

so

supervisorctl signal HUP all

would send SIGHUP to all processes managed by supervisor.

Until 3.2.0, you instead could use supervisorctl status to list the pids of the managed processes. Then use kill to send signals to those pids. With a little sed magic, you can even extract those pids to be acceptable as input to the kill command:

kill -HUP `bin/supervisorctl status | sed -n '/RUNNING/s/.*pid \([[:digit:]]\+\).*/\1/p'`

would also send SIGHUP to all active processes under supervisord control.

like image 196
Martijn Pieters Avatar answered Sep 21 '22 15:09

Martijn Pieters


As of 3.2.0, you CAN now send arbitrary signals to processes!

$ supervisord --version
3.2.0


$ supervisorctl signal help
Error: signal requires a signal name and a process name
signal <signal name> <name>     Signal a process
signal <signal name> <gname>:*      Signal all processes in a group
signal <signal name> <name> <name>  Signal multiple processes or groups
signal <signal name> all        Signal all processes


$ supervisorctl signal HUP gateway
gateway: signalled
like image 37
keen Avatar answered Sep 19 '22 15:09

keen