Anyway to get the ID of processes created by Supervisord?
Asked Answered
F

3

25

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?

Freberg answered 1/12, 2012 at 19:20 Comment(0)
D
27

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.

Devoice answered 1/12, 2012 at 21:16 Comment(2)
cheers Martijn. Irrelevant now thanks to your earlier answer :) Still cannot get group commands and restart working though.Freberg
Surprising that there's no straight forward way to do this. But this works like a charmTolbert
T
17

You can now do the following:

sudo supervisorctl pid all
sudo supervisorctl pid myprogramname
Tuckie answered 26/2, 2016 at 11:47 Comment(0)
R
0

System centos7

command:

ps -ef|grep $(cat /tmp/supervisord.pid)|grep -v grep |grep -v supervisord|awk '{print $2}'

The file /tmp/supervisord.pid records the supervisord id.

You can get child process by ps -ef|grep ${fatherProcess}

Rapine answered 5/3, 2019 at 23:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.