move RunApp() to app component
This commit is contained in:
parent
e35e7796ac
commit
d7e96f4f3d
5 changed files with 20 additions and 21 deletions
11
app/app.go
11
app/app.go
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"git.sr.ht/~cco/go-scopes/config"
|
"git.sr.ht/~cco/go-scopes/config"
|
||||||
"git.sr.ht/~cco/go-scopes/lib"
|
"git.sr.ht/~cco/go-scopes/lib"
|
||||||
|
"git.sr.ht/~cco/go-scopes/lib/context"
|
||||||
"git.sr.ht/~cco/go-scopes/lib/message"
|
"git.sr.ht/~cco/go-scopes/lib/message"
|
||||||
"git.sr.ht/~cco/go-scopes/logging"
|
"git.sr.ht/~cco/go-scopes/logging"
|
||||||
)
|
)
|
||||||
|
@ -52,3 +53,13 @@ func step(ctx lib.Context, sig <-chan os.Signal) bool {
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set up and start the application
|
||||||
|
|
||||||
|
func RunApp(cfg lib.Config) {
|
||||||
|
ctx := context.AppContext(cfg)
|
||||||
|
appCfg := cfg.(*Cfg)
|
||||||
|
logging.Setup(ctx, appCfg.Logging, appCfg.Home)
|
||||||
|
cfg.Starter()(ctx)
|
||||||
|
ctx.WaitGroup().Wait()
|
||||||
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ require git.sr.ht/~cco/go-scopes v0.1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/mattn/go-colorable v0.1.12 // indirect
|
github.com/mattn/go-colorable v0.1.12 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||||
github.com/rs/zerolog v1.29.1 // indirect
|
github.com/rs/zerolog v1.29.1 // indirect
|
||||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 // indirect
|
golang.org/x/sys v0.8.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
replace git.sr.ht/~cco/go-scopes => ../../../scopes
|
replace git.sr.ht/~cco/go-scopes => ../../../scopes
|
||||||
|
|
|
@ -2,12 +2,15 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
|
||||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
|
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
|
||||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
|
||||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||||
|
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||||
|
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc=
|
github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc=
|
||||||
github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU=
|
github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU=
|
||||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 h1:foEbQz/B0Oz6YIqu/69kfXPYeFQAuuMYFkjaqXzl5Wo=
|
|
||||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||||
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
|
|
@ -3,9 +3,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"demo/etc"
|
"demo/etc"
|
||||||
|
|
||||||
"git.sr.ht/~cco/go-scopes"
|
"git.sr.ht/~cco/go-scopes/app"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
scopes.RunApp(etc.Config())
|
app.RunApp(etc.Config())
|
||||||
}
|
}
|
||||||
|
|
15
scopes.go
15
scopes.go
|
@ -1,16 +1 @@
|
||||||
package scopes
|
package scopes
|
||||||
|
|
||||||
import (
|
|
||||||
"git.sr.ht/~cco/go-scopes/app"
|
|
||||||
"git.sr.ht/~cco/go-scopes/lib"
|
|
||||||
"git.sr.ht/~cco/go-scopes/lib/context"
|
|
||||||
"git.sr.ht/~cco/go-scopes/logging"
|
|
||||||
)
|
|
||||||
|
|
||||||
func RunApp(cfg lib.Config) {
|
|
||||||
ctx := context.AppContext(cfg)
|
|
||||||
appCfg := cfg.(*app.Cfg)
|
|
||||||
logging.Setup(ctx, appCfg.Logging, appCfg.Home)
|
|
||||||
cfg.Starter()(ctx)
|
|
||||||
ctx.WaitGroup().Wait()
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue