Commit 9e6ece7a authored by Julien Muchembled's avatar Julien Muchembled

Log signals that are sent to kill subprocesses and increase default log level

We currently have issues with OpenVPN hook scripts that aren't always killed
at exit. Such orphan processes prevent re6st from starting again (EADDRINUSE).

We want to know if it's an OpenVPN that does not exit cleanly on TERM,
or if it sometimes does not exit at all after 5s (then re6st sends a KILL
signal and at that point we should indeed make sure that any subprocess is
also KILLed).
parent 29d7fc03
...@@ -36,7 +36,7 @@ def getConfig(): ...@@ -36,7 +36,7 @@ def getConfig():
help="Path to re6stnet state directory:\n" help="Path to re6stnet state directory:\n"
"- cache.db: cache of network parameters and peer addresses\n" "- cache.db: cache of network parameters and peer addresses\n"
"- babeld.state: see option -S of babeld\n") "- babeld.state: see option -S of babeld\n")
_('-v', '--verbose', default=1, type=int, metavar='LEVEL', _('-v', '--verbose', default=2, type=int, metavar='LEVEL',
help="Log level of re6stnet itself. 0 disables logging. 1=WARNING," help="Log level of re6stnet itself. 0 disables logging. 1=WARNING,"
" 2=INFO, 3=DEBUG, 4=TRACE. Use SIGUSR1 to reopen log." " 2=INFO, 3=DEBUG, 4=TRACE. Use SIGUSR1 to reopen log."
" See also --babel-verb and --verb for logs of spawned processes.") " See also --babel-verb and --verb for logs of spawned processes.")
......
...@@ -155,6 +155,7 @@ exit = exit() ...@@ -155,6 +155,7 @@ exit = exit()
class Popen(subprocess.Popen): class Popen(subprocess.Popen):
def __init__(self, *args, **kw): def __init__(self, *args, **kw):
self._args = tuple(args[0] if args else kw['args'])
try: try:
super(Popen, self).__init__(*args, **kw) super(Popen, self).__init__(*args, **kw)
except OSError, e: except OSError, e:
...@@ -162,6 +163,11 @@ class Popen(subprocess.Popen): ...@@ -162,6 +163,11 @@ class Popen(subprocess.Popen):
raise raise
self.returncode = -1 self.returncode = -1
def send_signal(self, sig):
logging.info('Sending signal %s to pid %s %r',
sig, self.pid, self._args)
super(Popen, self).send_signal(sig)
def stop(self): def stop(self):
if self.pid and self.returncode is None: if self.pid and self.returncode is None:
self.terminate() self.terminate()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment