Solve issue of handling sigchld when dunning in a docker (#355)

If Patroni was started in a docker with pid=1 it will execute itself
with the same arguments. The original process will take care about init
process duties, i.e. handle sigchld and reap dead orphan processes.
Also it will forward SIGINT, SIGHUP, SIGTERM and some other signals to
the real Patroni process.
This commit is contained in:
Alexander Kukushkin
2016-11-22 16:22:47 +01:00
committed by GitHub
parent 038b5aed72
commit 28b00dea16
9 changed files with 102 additions and 87 deletions
+1 -19
View File
@@ -2,25 +2,7 @@ import unittest
from mock import Mock, patch
from patroni.exceptions import PatroniException
from patroni.utils import reap_children, Retry, RetryFailedError, sigchld_handler, sleep
def time_sleep(_):
sigchld_handler(None, None)
class TestUtils(unittest.TestCase):
@patch('time.sleep', Mock())
def test_reap_children(self):
self.assertIsNone(reap_children())
with patch('os.waitpid', Mock(return_value=(0, 0))):
sigchld_handler(None, None)
self.assertIsNone(reap_children())
@patch('time.sleep', time_sleep)
def test_sleep(self):
self.assertIsNone(sleep(0.01))
from patroni.utils import Retry, RetryFailedError
@patch('time.sleep', Mock())