implemented api handlers

This commit is contained in:
ston1th 2021-04-08 00:34:54 +02:00
commit 372915e24d
15 changed files with 302 additions and 73 deletions

View file

@ -4,6 +4,7 @@ import (
"bytes"
"context"
"crypto/sha256"
"fmt"
"io"
"io/ioutil"
"os"
@ -51,7 +52,11 @@ func (ha *HAProxyManager) checkConfig(ctx context.Context, lbs Config) (hash []b
return
}
hash = h.Sum(nil)
return hash, exec.CommandContext(ctx, "haproxy", "-c", "-f", tmp.Name()).Run()
out, err := exec.CommandContext(ctx, "haproxy", "-c", "-f", tmp.Name()).CombinedOutput()
if err != nil {
err = fmt.Errorf("%s:%w", string(out), err)
}
return hash, err
}
func (ha *HAProxyManager) UpdateConfig(ctx context.Context, lbs Config) error {