airbnb / nerve

A service registration daemon that performs health checks; companion to airbnb/synapse
MIT License
942 stars 151 forks source link

service_watcher does not exit properly in long sleep loop #54

Closed martinrhoads closed 7 years ago

martinrhoads commented 10 years ago

I am noticing that the service_watcher sleep loop is not configured to check for $EXIT during long sleep loops, as per: https://github.com/airbnb/nerve/blob/master/lib/nerve/service_watcher.rb#L72

This is causing me to experience timeouts when stopping the application. I currently have a single listener with a check_interval set to 10. I am able to reproduce this with the following method:

root@i-ef5077bc:~# for i in seq{1..10}; do (sv stop nerve > /dev/null && sv start nerve > /dev/null  ) ; echo status is $?; sleep 1; done
status is 0
status is 1
status is 0
status is 1
status is 0
status is 1
status is 0
status is 1
status is 0
status is 1

This patch in this PR fixes the issue for me: https://github.com/airbnb/nerve/pull/53

root@i-ef5077bc:/opt/smartstack/nerve/src# for i in seq{1..10}; do (sv stop nerve > /dev/null && sv start nerve > /dev/null  ) ; echo status is
 $?; sleep 1; done
status is 0
status is 0
status is 0
status is 0
status is 0
status is 0
status is 0
status is 0
status is 0
status is 0
rdeusser commented 7 years ago

This issue can be closed now yeah?

jolynch commented 7 years ago

Yes, we should be good here.