Skip to content

Commit

Permalink
spin up as embedded lib
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardoOliveira committed May 22, 2024
1 parent 1def746 commit 3192418
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions core/runtime/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ var Cfg *Config
var dataPath = "/data"

func init() {
dirname, err := os.UserHomeDir()
if err != nil {
log.Fatal(err)
}
log.Println(dirname)
dataPath = filepath.Join(dirname, "mmp")

viper.BindEnv("DATA_PATH")
if viper.GetString("DATA_PATH") != "" {
dataPath = viper.GetString("DATA_PATH")
Expand All @@ -61,9 +68,9 @@ func init() {
viper.SetDefault("server.port", v)
}
if v := viper.GetString("LIBRARY_PATH"); v == "" {
viper.SetDefault("library.path", "/library")
viper.SetDefault("library.path", filepath.Join(dirname, "mmp", "library"))
} else {
viper.SetDefault("library.path", v)
viper.SetDefault("library.path", filepath.Join(dirname, "mmp", "library"))
}
if v := viper.GetString("MODEL_RENDER_COLOR"); v == "" {
viper.SetDefault("render.model_color", "#167DF0")
Expand All @@ -88,7 +95,7 @@ func init() {
viper.SetConfigType("toml")
viper.AutomaticEnv()

err := viper.ReadInConfig()
err = viper.ReadInConfig()
if err != nil {
log.Println(err)
}
Expand Down

0 comments on commit 3192418

Please sign in to comment.