mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Merge pull request #18 from CyberDem0n/master
Set handler of SIGCHLD to SIG_IGN
This commit is contained in:
+1
-12
@@ -17,17 +17,6 @@ def sigterm_handler(signo, stack_frame):
|
||||
sys.exit()
|
||||
|
||||
|
||||
# handle SIGCHILD, since we are the equivalent of the INIT process
|
||||
def sigchld_handler(signo, stack_frame):
|
||||
try:
|
||||
while True:
|
||||
ret = os.waitpid(-1, os.WNOHANG)
|
||||
if ret == (0, 0):
|
||||
break
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
class Governor:
|
||||
|
||||
def __init__(self, config):
|
||||
@@ -78,8 +67,8 @@ class Governor:
|
||||
|
||||
def main():
|
||||
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.INFO)
|
||||
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
|
||||
signal.signal(signal.SIGTERM, sigterm_handler)
|
||||
signal.signal(signal.SIGCHLD, sigchld_handler)
|
||||
|
||||
if len(sys.argv) < 2 or not os.path.isfile(sys.argv[1]):
|
||||
print('Usage: {} config.yml'.format(sys.argv[0]))
|
||||
|
||||
+1
-11
@@ -1,4 +1,3 @@
|
||||
import os
|
||||
import psycopg2
|
||||
import requests
|
||||
import subprocess
|
||||
@@ -7,7 +6,7 @@ import time
|
||||
import unittest
|
||||
import yaml
|
||||
|
||||
from governor import Governor, main, sigchld_handler, sigterm_handler
|
||||
from governor import Governor, main, sigterm_handler
|
||||
from test_ha import true, false
|
||||
from test_postgresql import Postgresql, subprocess_call, psycopg2_connect
|
||||
from test_etcd import requests_get, requests_put, requests_delete
|
||||
@@ -22,10 +21,6 @@ def nop(*args, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def os_waitpid(a, b):
|
||||
return (0, 0)
|
||||
|
||||
|
||||
def time_sleep(_):
|
||||
raise Exception()
|
||||
|
||||
@@ -89,8 +84,3 @@ class TestGovernor(unittest.TestCase):
|
||||
time.sleep = time_sleep
|
||||
g.postgresql.sync_from_leader = false
|
||||
self.assertRaises(Exception, g.initialize)
|
||||
|
||||
def test_sigchld_handler(self):
|
||||
sigchld_handler(None, None)
|
||||
os.waitpid = os_waitpid
|
||||
sigchld_handler(None, None)
|
||||
|
||||
Reference in New Issue
Block a user