i am running a headless selenium process along a jenkins server on an AMI linux box, all managed by runit.

the problem is that issuing "sv stop selenium" or "sv reload selenium" do not term or kill the old instance along its child processes, but merely detach them from the runsv process, so they continue to run without runit knowing about them, resulting in a failing restart try of the service.

i think my question is kind of related to this: How to write runit custom stop script

meaning: i should probably try a custom d control script, in order to manually clean up.

I followed this idea: https://stackoverflow.com/questions/392022/best-way-to-kill-all-child-processes

However, cat'ing the pid from /etc/sv/selenium/supervise/pid and forwarding it to the loop didn't do any difference.

Any advice?

sv run script:


exec 2>&1
exec chpst -u jenkins -U jenkins /usr/bin/xvfb-run \
--server-args="-screen 0 1024x768x32" \
/usr/bin/java -jar /usr/local/bin/selenium-server-standalone-2.42.1.jar \
-ensureCleanSession \
  • Because your child process wandered off to a new process group - so you can't get there from here. The answer from @András Korn is correct. – Avery Payne Dec 17 '14 at 1:09

If you add -P to the chpst command line, chpst will create a new process group for your service. Then in your custom 'd' script you can read pid and kill -TERM -pid to send the TERM signal to the entire process group.

This should work as long as no child process creates its own process group.

However, it might be cleaner to start your xvfb and java separately (split these into two runit services).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.