blob: 922c6d09b01b7f8d5feb3572846faf5f1552685f [file] [log] [blame]
William Lallemand7755f9f2018-09-11 16:51:30 +02001#!/usr/bin/python
2"""
3Python wrapper example to test socketpair protocol
4./test-socketpair.py test.cfg
5
6use sockpair@${FD1} and sockpair@${FD2} in your configuration file
7
8"""
9
10import socket, os, sys
11
12s = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM)
13os.set_inheritable(s[0].fileno(), 1)
14os.set_inheritable(s[1].fileno(), 1)
15
16FD1 = s[0].fileno()
17FD2 = s[1].fileno()
18
19print("FD1={} FD2={}".format(FD1, FD2))
20
21os.environ["FD1"] = str(FD1)
22os.environ["FD2"] = str(FD2)
23
24cmd = ["./haproxy",
25 "-f",
26 "{}".format(sys.argv[1])
27]
28os.execve(cmd[0], cmd, os.environ)