File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,18 @@ func ExampleGroup_Run() {
39
39
g := graceful.Group {
40
40
graceful.RunnerType {
41
41
StartFunc : func (ctx context.Context ) error {
42
- return s .ListenAndServe ()
42
+ errCh := make (chan error )
43
+ go func () {
44
+ errCh <- s .ListenAndServe ()
45
+ close (errCh )
46
+ }()
47
+
48
+ select {
49
+ case <- ctx .Done ():
50
+ return ctx .Err ()
51
+ case err := <- errCh :
52
+ return err
53
+ }
43
54
},
44
55
StopFunc : func (ctx context.Context ) error {
45
56
if err := s .Shutdown (ctx ); err != nil {
@@ -49,14 +60,13 @@ func ExampleGroup_Run() {
49
60
return nil
50
61
},
51
62
},
52
- // TODO: populate with more runners.
53
63
}
54
64
55
65
if err := g .Run (ctx ,
56
66
graceful .WithStopSignals (syscall .SIGTERM , syscall .SIGINT ),
57
67
graceful .WithStopTimeout (1 * time .Minute ),
58
68
graceful .WithStoppingCh (stoppingCh ),
59
69
); err != nil {
60
- panic (err ) // TODO: handle error appropriately.
70
+ panic (err )
61
71
}
62
72
}
You can’t perform that action at this time.
0 commit comments