I am try to reproduce situation when runsv under some catastrophic
failure,
when runsv got killed, it will restart, but my test daemon "memcached"
still running on background, eventually it will start memcached twice.
How
could I avoid this from happening? Seems fault handling isn't that
great on
this matter.
It almost sounds like you need to chain-load memcached using chpst. If
memcached has internal code to change its process group then it is
"escaping" supervision, which means that runsv is not in direct control
of it. To fix this, your ./run script would be similar to:
#!/bin/sh
exec 2>&1
exec chpst -P memcached
See http://smarden.org/runit/chpst.8.html for details. This would cause
memcached to be "captive" to the runsv process. Try the change with
chpst and see what happens. You may find other issues you're not seeing
after you make this change; check the log with tail -f /path/to/log/file
and see if it is restarting over and over (a "restart loop").