Skip to content

Commit

Permalink
Setup signal handler before creating dcs
Browse files Browse the repository at this point in the history
Otherwise it was swallowing SysExit exception in an infinite loop.
  • Loading branch information
Alexander Kukushkin committed Jun 21, 2016
1 parent 5683880 commit 8150f17
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions patroni/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
class Patroni(object):

def __init__(self):
self.setup_signal_handlers()

self.version = __version__
self.config = Config()
self.dcs = get_dcs(self.config)
Expand All @@ -31,10 +33,6 @@ def __init__(self):
self.nap_time = self.config['loop_wait']
self.next_run = time.time()

self._reload_config_scheduled = False
self._received_sighup = False
self._received_sigterm = False

def load_dynamic_configuration(self):
while True:
try:
Expand Down Expand Up @@ -114,6 +112,8 @@ def run(self):
self.schedule_next_run()

def setup_signal_handlers(self):
self._received_sighup = False
self._received_sigterm = False
signal.signal(signal.SIGHUP, self.sighup_handler)
signal.signal(signal.SIGTERM, self.sigterm_handler)
signal.signal(signal.SIGCHLD, sigchld_handler)
Expand All @@ -124,7 +124,6 @@ def main():
logging.getLogger('requests').setLevel(logging.WARNING)

patroni = Patroni()
patroni.setup_signal_handlers()
try:
patroni.run()
except KeyboardInterrupt:
Expand Down

0 comments on commit 8150f17

Please sign in to comment.