diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:18:05 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:18:05 +0000 |
commit | b46aad6df449445a9fc4aa7b32bd40005438e3f7 (patch) | |
tree | 751aa858ca01f35de800164516b298887382919d /tests/unit/test-inherited-fd.py | |
parent | Initial commit. (diff) | |
download | haproxy-b46aad6df449445a9fc4aa7b32bd40005438e3f7.tar.xz haproxy-b46aad6df449445a9fc4aa7b32bd40005438e3f7.zip |
Adding upstream version 2.9.5.upstream/2.9.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/unit/test-inherited-fd.py')
-rw-r--r-- | tests/unit/test-inherited-fd.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/unit/test-inherited-fd.py b/tests/unit/test-inherited-fd.py new file mode 100644 index 0000000..b4b076c --- /dev/null +++ b/tests/unit/test-inherited-fd.py @@ -0,0 +1,23 @@ +#!/usr/bin/python +""" +Python wrapper example to test the fd@ function, +You have to bind on fd@${NEWFD} in your haproxy configuration + +The configuration parsing should still work upon a reload with the master-worker +mode. + +""" + +import socket, subprocess, fcntl + +s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) +flags = fcntl.fcntl(s.fileno(), fcntl.F_GETFD) +flags &= ~fcntl.FD_CLOEXEC +fcntl.fcntl(s.fileno(), fcntl.F_SETFD, flags) + +s.bind((socket.gethostname(), 5555)) +s.listen(1) +FD = s.fileno() + +subprocess.Popen('NEWFD={} ./haproxy -W -f haproxy.cfg'.format(FD), shell=True, close_fds=False) |