@@ -0,0 +1,1512 @@
+package router;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Paths;%0A%0Apublic class HAProxyController %7B%0A    private String executablePath;%0A%0A    public HAProxyController(String executablePath) %7B%0A        this.executablePath = executablePath;%0A        if (!this.executablePath.endsWith(%22haproxy%22)) %7B%0A            if (!this.executablePath.endsWith(%22/%22)) %7B%0A                this.executablePath += %22/%22;%0A            %7D%0A            this.executablePath += %22haproxy%22;%0A        %7D%0A%0A        killAll(%22haproxy%22);%0A    %7D%0A%0A    public void start() throws Exception %7B%0A        File conf = new File(%22/tmp/haproxy.conf%22);%0A        if (!conf.exists()) %7B%0A            throw new Exception(%22/tmp/haproxy.conf does not exists%22);%0A        %7D%0A%0A        String command = executablePath + %22 -f /tmp/haproxy.conf -p /tmp/haproxy.pid%22;%0A        runCommand(command);%0A    %7D%0A%0A    public void stop() throws Exception %7B%0A        killAll(%22haproxy%22);%0A    %7D%0A%0A    public void reload() throws Exception %7B%0A        String pid = new String(Files.readAllBytes(Paths.get(%22/tmp/haproxy.pid%22)));%0A        String command = executablePath + %22 -f /tmp/haproxy.conf -p /tmp/haproxy.pid -sf %22 + pid;%0A        runCommand(command);%0A    %7D%0A%0A    private void killAll(String processName) %7B%0A        runCommand(%22killall %22 + processName);%0A    %7D%0A%0A    private void runCommand(String command) %7B%0A        try %7B%0A            Runtime.getRuntime().exec(command);%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%7D%0A

Add hacky HAProxy client