Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anyway to get the ID of processes created by Supervisord?

Tags:

I need the process ID of processes created using supervisord for use in a script. Processes spawned by supervisord don't create .pid files in their default directories, if at all.

How do I get the process ID of a supervisord child process?

like image 929
user1561108 Avatar asked Dec 01 '12 19:12

user1561108


People also ask

How do I check my Supervisorctl status?

The supervisor service runs automatically after installation. You can check its status: sudo systemctl status supervisor.

What is Supervisorctl command?

supervisorctl - supervisorctl Documentation Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems. It shares some of the same goals of programs like launchd, daemontools, and runit.

What is supervisord conf?

supervisord. conf is a Windows-INI-style (Python ConfigParser) file. It has sections (each denoted by a [header]) and key / value pairs within the sections. The sections and their allowable values are described below.


1 Answers

As of supervisor version 3 you can use the supervisorctl pid <name> command to list pids of managed processes:

supervisorctl pid programname 

Use supervisorctl pid all to get a newline-separated list of pids of all managed processes.

For older supervisord versions, you are stuck with supervisord status, but with a little awk, sed and paste massaging, you can extract those pids to be acceptable as input to other commands:

echo `bin/supervisorctl status | grep RUNNING | awk -F' ' '{print $4}' | sed -e 's/,$//' | paste -sd' '` 

would list all pids of running programs as a space-separated list. Replace echo with a kill -HUP command to send them all the SIGHUP signal, for example.

like image 115
Martijn Pieters Avatar answered Nov 08 '22 11:11

Martijn Pieters