Upstart service is responsible for creating a gearman workers which run in parallel as number of cpus with the help of gnu-parallel. To understand the problem you can read my stackoverflow post which describes how to run workers in parallel.https://stackoverflow.com/q/45127927/3615504Upstart service: workon.conf# workondescription worker loadstart on runlevel [2345]stop on runlevel [!2345]respawnscript  exec seq 1000000 | parallel -N0 --joblog out.log ./workerend scriptOright. so above service is started $ sudo service workon startworkon start/running, process 46204620 is the process id of service workon.4 workers will be spawned as per cpu cores. for example.___________________Name   |  PIDworker    1011worker    1012worker    1013worker    1014perl      1000perl is the process which is running gnu-parallel.And, gnu-parallel is responsible for running parallel worker processes.Now, the problem is.If I kill the workon service.$ sudo kill 4620The service has instruction to re-spawn if killed so it restarts. But, the processes created by the service are not killed. Which means it creates a new set of processes. Now we have 2 perl and 8 workers.Name   |  PIDworker    1011worker    1012worker    1013worker    1014worker    2011worker    2012worker    2013worker    2014perl      1000perl      2000If you ask me, the old process which abandon by service, are they zombies?Well, the answer is no. They are alive cuz I tested them. Everytime the service dies it creates a new set.Well, this is one problem. Another problem is with the gnu-parallel.Lets say I started the service as fresh. Service is running good.I ran this command to kill the gnu-parallel, i.e. perl $ sudo kill 1000This doesn't kill the workers,and they again left without any parent. But, the workon service intercept the death of perl and respawn a new set of workers. This time we have 1 perl and 8 workers. All 8 workers are alive. 4 of them with parent and 4 are orphan.Now, how do I solve this problem? I want kill all processes created by the service whenever it crashes.
How to killall the process created by upstart service which is killed (not stopped)
services;upstart;parallelism;gnu parallel