TUN-3706: Quit if any origin service fails to start
This commit is contained in:
parent
32336859f8
commit
b855e33327
|
@ -339,7 +339,9 @@ func StartServer(
|
|||
errC <- metrics.ServeMetrics(metricsListener, shutdownC, readinessCh, log)
|
||||
}()
|
||||
|
||||
ingressRules.StartOrigins(&wg, log, shutdownC, errC)
|
||||
if err := ingressRules.StartOrigins(&wg, log, shutdownC, errC); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
reconnectCh := make(chan origin.ReconnectSignal, 1)
|
||||
if c.IsSet("stdin-control") {
|
||||
|
|
|
@ -113,12 +113,18 @@ func (ing Ingress) IsEmpty() bool {
|
|||
}
|
||||
|
||||
// StartOrigins will start any origin services managed by cloudflared, e.g. proxy servers or Hello World.
|
||||
func (ing Ingress) StartOrigins(wg *sync.WaitGroup, log *zerolog.Logger, shutdownC <-chan struct{}, errC chan error) {
|
||||
func (ing Ingress) StartOrigins(
|
||||
wg *sync.WaitGroup,
|
||||
log *zerolog.Logger,
|
||||
shutdownC <-chan struct{},
|
||||
errC chan error,
|
||||
) error {
|
||||
for _, rule := range ing.Rules {
|
||||
if err := rule.Service.start(wg, log, shutdownC, errC, rule.Config); err != nil {
|
||||
log.Error().Msgf("Error starting local service %s: %s", rule.Service, err)
|
||||
return errors.Wrapf(err, "Error starting local service %s", rule.Service)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CatchAll returns the catch-all rule (i.e. the last rule)
|
||||
|
|
|
@ -123,7 +123,7 @@ func TestProxySingleOrigin(t *testing.T) {
|
|||
|
||||
var wg sync.WaitGroup
|
||||
errC := make(chan error)
|
||||
ingressRule.StartOrigins(&wg, &log, ctx.Done(), errC)
|
||||
require.NoError(t, ingressRule.StartOrigins(&wg, &log, ctx.Done(), errC))
|
||||
|
||||
client := NewClient(ingressRule, testTags, &log)
|
||||
t.Run("testProxyHTTP", testProxyHTTP(t, client))
|
||||
|
@ -256,7 +256,7 @@ func TestProxyMultipleOrigins(t *testing.T) {
|
|||
ctx, cancel := context.WithCancel(context.Background())
|
||||
errC := make(chan error)
|
||||
var wg sync.WaitGroup
|
||||
ingress.StartOrigins(&wg, &log, ctx.Done(), errC)
|
||||
require.NoError(t, ingress.StartOrigins(&wg, &log, ctx.Done(), errC))
|
||||
|
||||
client := NewClient(ingress, testTags, &log)
|
||||
|
||||
|
|
Loading…
Reference in New Issue