File tree Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ require (
66 github.com/expr-lang/expr v1.17.5
77 github.com/go-spring/gs-assert v1.0.2
88 github.com/go-spring/gs-mock v0.0.4
9- github.com/go-spring/log v0.0.4
9+ github.com/go-spring/log v0.0.5
1010 github.com/magiconair/properties v1.8.10
1111 github.com/pelletier/go-toml v1.9.5
1212 github.com/spf13/cast v1.9.2
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ github.com/go-spring/gs-assert v1.0.2 h1:9vDppl7ZwMvQE4c83ac7GzN0VxZC5BrQue7dND7
66github.com/go-spring/gs-assert v1.0.2 /go.mod h1:FfibkqWz4HUBpbig1cKMlzW8Ha7RywTB93f1Q/NuF9I =
77github.com/go-spring/gs-mock v0.0.4 h1:f34YN+ntXflfn13aLa3ZVCB78IG7wWZGK4y5tB+OGpI =
88github.com/go-spring/gs-mock v0.0.4 /go.mod h1:QK0PqZ+Vu9F+BU97zl8fip5XKibvDSoN+ofky413Z6Q =
9- github.com/go-spring/log v0.0.4 h1:gmYPCBt9jH8k5FsbS7WvICiK1aN9mEqXwz2XNvGxKfQ =
10- github.com/go-spring/log v0.0.4 /go.mod h1:9SWgPEVWSGgloRTGR7niBliqfwC5UCjPUOl2jyJOimM =
9+ github.com/go-spring/log v0.0.5 h1:a8yiGmZTS7MPYvYvePXtc0hIdaQ76pLdsXt8iJwgQBQ =
10+ github.com/go-spring/log v0.0.5 /go.mod h1:9SWgPEVWSGgloRTGR7niBliqfwC5UCjPUOl2jyJOimM =
1111github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38 =
1212github.com/google/go-cmp v0.5.9 /go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY =
1313github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE =
Original file line number Diff line number Diff line change @@ -25,11 +25,6 @@ import (
2525
2626type AppStarter struct {}
2727
28- // Run runs the app and waits for an interrupt signal to exit.
29- func (s * AppStarter ) Run () {
30- s .RunWith (nil )
31- }
32-
3328// initApp initializes the app.
3429func (s * AppStarter ) initApp () error {
3530 printBanner ()
@@ -43,6 +38,11 @@ func (s *AppStarter) initApp() error {
4338 return nil
4439}
4540
41+ // Run runs the app and waits for an interrupt signal to exit.
42+ func (s * AppStarter ) Run () {
43+ s .RunWith (nil )
44+ }
45+
4646// RunWith runs the app with a given function and waits for an interrupt signal to exit.
4747func (s * AppStarter ) RunWith (fn func (ctx context.Context ) error ) {
4848 var err error
@@ -54,7 +54,10 @@ func (s *AppStarter) RunWith(fn func(ctx context.Context) error) {
5454 if err = s .initApp (); err != nil {
5555 return
5656 }
57- err = gs_app .GS .RunWith (fn )
57+ if err = gs_app .GS .RunWith (fn ); err != nil {
58+ return
59+ }
60+ log .Destroy ()
5861}
5962
6063// RunAsync runs the app asynchronously and returns a function to stop the app.
@@ -65,5 +68,8 @@ func (s *AppStarter) RunAsync() (func(), error) {
6568 if err := gs_app .GS .Start (); err != nil {
6669 return nil , err
6770 }
68- return func () { gs_app .GS .Stop () }, nil
71+ return func () {
72+ gs_app .GS .Stop ()
73+ log .Destroy ()
74+ }, nil
6975}
You can’t perform that action at this time.
0 commit comments