def makeService(opt): """Make a service :params opt: dictionary-like object with 'freq', 'config' and 'messages' :returns: twisted.application.internet.TimerService that at opt['freq'] checks for stale processes in opt['config'], and sends restart messages through opt['messages'] """ restarter, path = parseConfig(opt) now = time.time() checker = functools.partial(check, path, now) beatcheck = tainternet.TimerService(opt['freq'], run, restarter, checker, time.time) beatcheck.setName('beatcheck') return heart.wrapHeart(beatcheck)
def makeService(opt): """Make a service :params opt: dictionary-like object with 'freq', 'config' and 'messages' :returns: twisted.application.internet.TimerService that at opt['freq'] checks for stale processes in opt['config'], and sends restart messages through opt['messages'] """ restarter, path = beatcheck.parseConfig(opt) pool = client.HTTPConnectionPool(reactor) agent = client.Agent(reactor=reactor, pool=pool) settings = Settings(reactor=reactor, agent=agent) states = {} checker = functools.partial(check, settings, states, path) httpcheck = tainternet.TimerService(opt['freq'], run, restarter, checker) httpcheck.setName('httpcheck') return heart.wrapHeart(httpcheck)