1

I'm using supervisord for managing process.

(To avoid zombie process, and other difficult thing to manage process)

Assume that I will run python script that using multiprocessing.

from multiprocessing import Process
import time

def fetch():
    while True:
        time.sleep(1)
        print("I'm still alive...")


def main():
    processes = [
        Process(target=fetch),
        Process(target=fetch),
        Process(target=fetch),
        Process(target=fetch),
        Process(target=fetch),
        Process(target=fetch),
        Process(target=fetch),
        Process(target=fetch),
        [And more process here...]
    ]
    for process in processes:
        process.start()

main()

Above code, fetch() create many processed and run it.

In this case, if processes that created by fetch() become zombie process,

supervisord managing it?(ex. Auto kill and restart)

Or, just managing root process only?

Thanks.

Hide
  • 3,199
  • 7
  • 41
  • 83

1 Answers1

2

Supervisord manages the child process, which is responsible for managing anything it spawns. However, if you want to ensure that all the subprocesses are stopped with the main process, use stopasgroup=true in the supervisord.conf file.

See related question: supervisord stopping child processes

tsnowlan
  • 3,472
  • 10
  • 15
  • I tried `stopasgroup=true` and `killasgroup=true` but it doesn't work. Assume that parent process id=1 and child id =2, 3. In this case if I kill process id=1, process_id=2,3 doesn't killed and new process is launched. – Hide Jul 30 '19 at 09:22
  • If the above is the extent of your code, the processes ending up zombies is from the multiprocessing handling and not supervisor. See related questions: https://stackoverflow.com/questions/18477320/python-multiprocessing-kill-processes and https://stackoverflow.com/questions/30506489/python-multiprocessing-leading-to-many-zombie-processes – tsnowlan Jul 30 '19 at 09:44
  • You're right. Child process have to handled by python code. – Hide Jul 31 '19 at 07:22