mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
Move the start of the UniversalExecutor's consulSyncer to initialize once
This should be handled via a sync.Once primative, but I don't want to unpack that atm.
This commit is contained in:
@@ -483,6 +483,7 @@ func (e *UniversalExecutor) SyncServices(ctx *ConsulContext) error {
|
||||
cs.SetServiceRegPrefix(consul.GenerateServicePrefix(e.ctx.AllocID, e.ctx.Task.Name))
|
||||
cs.SetAddrFinder(e.ctx.Task.FindHostAndPortFor)
|
||||
e.consulSyncer = cs
|
||||
go e.consulSyncer.Run()
|
||||
}
|
||||
if e.ctx != nil {
|
||||
syncerFn := func() error {
|
||||
@@ -492,7 +493,6 @@ func (e *UniversalExecutor) SyncServices(ctx *ConsulContext) error {
|
||||
}
|
||||
e.consulSyncer.AddPeriodicHandler(e.ctx.AllocID, syncerFn)
|
||||
}
|
||||
go e.consulSyncer.Run()
|
||||
err := e.consulSyncer.SyncServices() // Attempt to register immediately
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user