mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-12 14:35:14 +00:00
38ceb554fd
The code that is there to run some unit tests on some internal features was moved to tests/unit. Ideally it should be buildable from the main makefile though this is not yet the case. The code that is kept for experimentation purposes (hashes, syscall optimization etc) as well as some captures of the results was moved to tests/exp. A few totally obsolete files which couldn't build anymore and were not relevant to current versions were removed.
24 lines
655 B
Python
24 lines
655 B
Python
#!/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)
|