fixed reload bug
This commit is contained in:
parent
5de98614da
commit
ec57e1174c
1 changed files with 7 additions and 1 deletions
|
|
@ -27,6 +27,7 @@ type HAProxyManager struct {
|
|||
svc ServiceManager
|
||||
template *template.Template
|
||||
hash []byte
|
||||
reload bool
|
||||
}
|
||||
|
||||
func NewHAProxyManager(configFile, service string) (ha *HAProxyManager, err error) {
|
||||
|
|
@ -69,8 +70,10 @@ func (ha *HAProxyManager) updateConfig(ctx context.Context, lbs Config) error {
|
|||
return err
|
||||
}
|
||||
if bytes.Equal(ha.hash, hash) {
|
||||
ha.reload = false
|
||||
return nil
|
||||
}
|
||||
ha.reload = true
|
||||
file, err := os.OpenFile(ha.configFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -92,7 +95,10 @@ func (ha *HAProxyManager) UpdateConfig(ctx context.Context, lbs Config) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ha.reload {
|
||||
return ha.svc.Reload(ctx)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ha *HAProxyManager) Start(ctx context.Context) error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue