@@ -27,14 +27,13 @@ package host
27
27
import (
28
28
"context"
29
29
"encoding/json"
30
- "errors"
31
30
"fmt"
32
31
"net"
33
- "strings"
34
32
"sync"
35
33
"time"
36
34
37
35
"go.uber.org/fx"
36
+ "go.uber.org/multierr"
38
37
"golang.org/x/exp/maps"
39
38
"google.golang.org/grpc"
40
39
@@ -244,38 +243,28 @@ func (c *temporalImpl) Stop() error {
244
243
ctx , cancel := context .WithTimeout (context .Background (), 15 * time .Second )
245
244
defer cancel ()
246
245
247
- var errs [] string
246
+ var errs error
248
247
249
248
if c .enableWorker () {
250
249
c .shutdownWG .Add (1 )
251
- err := c .workerApp .Stop (ctx )
252
- if err != nil {
253
- errs = append (errs , err .Error ())
254
- }
250
+ errs = multierr .Combine (errs , c .workerApp .Stop (ctx ))
255
251
}
256
252
257
253
c .shutdownWG .Add (3 )
258
254
259
- c .frontendApp .Stop (ctx )
255
+ if err := c .frontendApp .Stop (ctx ); err != nil {
256
+ return err
257
+ }
260
258
for _ , historyApp := range c .historyApps {
261
- err := historyApp .Stop (ctx )
262
- if err != nil {
263
- errs = append (errs , err .Error ())
264
- }
259
+ errs = multierr .Combine (errs , historyApp .Stop (ctx ))
265
260
}
266
261
267
- err := c .matchingApp .Stop (ctx )
268
- if err != nil {
269
- errs = append (errs , err .Error ())
270
- }
262
+ errs = multierr .Combine (errs , c .matchingApp .Stop (ctx ))
271
263
272
264
close (c .shutdownCh )
273
265
c .shutdownWG .Wait ()
274
266
275
- if len (errs ) > 0 {
276
- return errors .New ("shutdown errors: " + strings .Join (errs , "; " ))
277
- }
278
- return nil
267
+ return errs
279
268
}
280
269
281
270
func (c * temporalImpl ) FrontendGRPCAddress () string {
@@ -443,7 +432,9 @@ func (c *temporalImpl) startFrontend(hosts map[primitives.ServiceName][]string,
443
432
c .adminClient = NewAdminClient (connection )
444
433
c .operatorClient = operatorservice .NewOperatorServiceClient (connection )
445
434
446
- feApp .Start (context .Background ())
435
+ if err := feApp .Start (context .Background ()); err != nil {
436
+ c .logger .Fatal ("unable to start frontend service" , tag .Error (err ))
437
+ }
447
438
448
439
startWG .Done ()
449
440
<- c .shutdownCh
@@ -537,7 +528,9 @@ func (c *temporalImpl) startHistory(
537
528
c .historyServices = append (c .historyServices , historyService )
538
529
c .historyNamespaceRegistries = append (c .historyNamespaceRegistries , namespaceRegistry )
539
530
540
- app .Start (context .Background ())
531
+ if err := app .Start (context .Background ()); err != nil {
532
+ c .logger .Fatal ("unable to start history service" , tag .Error (err ))
533
+ }
541
534
}
542
535
543
536
startWG .Done ()
@@ -600,7 +593,9 @@ func (c *temporalImpl) startMatching(hosts map[primitives.ServiceName][]string,
600
593
c .matchingApp = app
601
594
c .matchingService = matchingService
602
595
c .matchingNamespaceRegistry = namespaceRegistry
603
- app .Start (context .Background ())
596
+ if err := app .Start (context .Background ()); err != nil {
597
+ c .logger .Fatal ("unable to start matching service" , tag .Error (err ))
598
+ }
604
599
605
600
startWG .Done ()
606
601
<- c .shutdownCh
@@ -679,7 +674,9 @@ func (c *temporalImpl) startWorker(hosts map[primitives.ServiceName][]string, st
679
674
c .workerApp = app
680
675
c .workerService = workerService
681
676
c .workerNamespaceRegistry = namespaceRegistry
682
- app .Start (context .Background ())
677
+ if err := app .Start (context .Background ()); err != nil {
678
+ c .logger .Fatal ("unable to start worker service" , tag .Error (err ))
679
+ }
683
680
684
681
startWG .Done ()
685
682
<- c .shutdownCh
0 commit comments