Files
core/app/starter.go
T
2025-04-25 15:00:25 +03:00

47 lines
786 B
Go

package app
import (
"go.uber.org/fx"
"os"
"time"
uc "universe.mrlokop.dev/core/config"
"universe.mrlokop.dev/core/fs"
)
func StartApplication(
runDirectory string,
) error {
if runDirectory == "" {
runEnv := os.Getenv("UNIVERSE_RUN_PATH")
if runEnv == "" {
runDirectory = "."
} else {
runDirectory = runEnv
}
}
cfg := new(uc.UniverseConfig)
err := uc.LoadConfigFromDirectory(runDirectory, cfg)
if err != nil {
return err
}
app := NewUniverseApplication(cfg)
baseModule, err := Module.Create("$base", make(map[string]interface{}))
if err != nil {
return err
}
app.WithOption(
fx.StartTimeout(10*time.Minute),
fx.Supply(cfg),
fx.Provide(func() RunPath {
return fs.System.INodeAt(runDirectory)
}),
baseModule,
)
return app.Run()
}