airbnb / nerve

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

allow a no-watchers state #22

Closed igor47 closed 10 years ago

igor47 commented 10 years ago

in order to support the use case of dynamic registration, nerve should continue running even if it was started with no services defined in it's config. this re-structures the main thread to make that possible.

the main action of the main thread is to sleep, waiting for an interrupt. an interrupt triggers the reaping of existing watchers, of which there may be none.

as a byproduct, we create an interface to add additional watchers dynamically. a hypothetical future TCP server can call launch_watcher on the main class to register a new watcher. similarly, it can call reap_watcher to kill a watcher.

@brndnmtthws maybe this could be the basis of your new API? this is not yet tested. working on additional tests around exiting/signal handling in smartstack-cookbook

igor47 commented 10 years ago

@martinrhoads this might solve the current problem you're interested in re: restarts eating CPU in production. this resulted from how we refactored the cookbooks to install nerve even if no services are defined.

martinrhoads commented 10 years ago

seems reasonable assuming it's been tested adequately

nelgau commented 10 years ago

<3 this!

igor47 commented 10 years ago

tested in vagrant and on some production boxes, so merging