diff --git a/docs/httpok.rst b/docs/httpok.rst index 246f02b..083a709 100644 --- a/docs/httpok.rst +++ b/docs/httpok.rst @@ -118,6 +118,10 @@ Command-Line Syntax Disable "eager" monitoring: do not check the URL or emit mail if no monitored process is in the RUNNING state. +.. cmdoption:: -w , --delay= + + Number of seconds delay before really make a restart. + .. cmdoption:: The URL to which to issue a GET request. diff --git a/superlance/httpok.py b/superlance/httpok.py index b204317..d085b61 100644 --- a/superlance/httpok.py +++ b/superlance/httpok.py @@ -26,7 +26,7 @@ doc = """\ httpok.py [-p processname] [-a] [-g] [-t timeout] [-c status_code] [-b inbody] - [-m mail_address] [-s sendmail] URL + [-m mail_address] [-s sendmail] [-w delay_seconds] URL Options: @@ -81,6 +81,8 @@ -E -- not "eager": do not check URL / emit mail if no process we are monitoring is in the RUNNING state. + +-w -- specify number of seconds delay before really make a restart. URL -- The URL to which to issue a GET request. @@ -114,7 +116,7 @@ def usage(): class HTTPOk: connclass = None def __init__(self, rpc, programs, any, url, timeout, status, inbody, - email, sendmail, coredir, gcore, eager, retry_time): + email, sendmail, coredir, gcore, eager, delay, retry_time): self.rpc = rpc self.programs = programs self.any = any @@ -128,6 +130,7 @@ def __init__(self, rpc, programs, any, url, timeout, status, inbody, self.coredir = coredir self.gcore = gcore self.eager = eager + self.delay = delay self.stdin = sys.stdin self.stdout = sys.stdout self.stderr = sys.stderr @@ -272,6 +275,10 @@ def mail(self, email, subject, msg): def restart(self, spec, write): namespec = make_namespec(spec['group'], spec['name']) if spec['state'] is ProcessStates.RUNNING: + if self.delay and (spec['now']-spec['start'])