Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Check for new PID after reload. #269

Merged
merged 1 commit into from
Jul 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions marathon_lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,12 +562,12 @@ def config(apps, groups, bind_http_https, ssl_certs, templater,

def get_haproxy_pids():
try:
return subprocess.check_output(
return set(map(lambda i: int(i), subprocess.check_output(
"pidof haproxy",
stderr=subprocess.STDOUT,
shell=True)
shell=True).split()))
except subprocess.CalledProcessError as ex:
return ''
return set()


def reloadConfig():
Expand Down Expand Up @@ -596,10 +596,10 @@ def reloadConfig():
logger.info("reloading using %s", " ".join(reloadCommand))
try:
start_time = time.time()
pids = get_haproxy_pids()
old_pids = get_haproxy_pids()
subprocess.check_call(reloadCommand, close_fds=True)
# Wait until the reload actually occurs
while pids == get_haproxy_pids():
# Wait until the reload actually occurs and there's a new PID
while len(get_haproxy_pids() - old_pids) < 1:
time.sleep(0.1)
logger.debug("reload finished, took %s seconds",
time.time() - start_time)
Expand Down