2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 06:47:20 +08:00
Files
panel/internal/bootstrap/conf.go
2024-11-10 08:37:38 +08:00

44 lines
935 B
Go

package bootstrap
import (
"log"
"time"
"github.com/knadh/koanf/parsers/yaml"
"github.com/knadh/koanf/providers/file"
"github.com/knadh/koanf/v2"
"github.com/TheTNB/panel/internal/app"
"github.com/TheTNB/panel/pkg/io"
)
func initConf() {
config := "/usr/local/etc/panel/config.yml"
if !io.Exists(config) {
config = "config.yml"
}
app.Conf = koanf.New(".")
if err := app.Conf.Load(file.Provider(config), yaml.Parser()); err != nil {
log.Fatalf("failed to load config: %v", err)
}
}
func initGlobal() {
app.Key = app.Conf.MustString("app.key")
if len(app.Key) != 32 {
log.Fatalf("app key must be 32 characters")
}
app.Root = app.Conf.MustString("app.root")
app.Version = "2.3.18"
app.Locale = app.Conf.MustString("app.locale")
// 初始化时区
loc, err := time.LoadLocation(app.Conf.MustString("app.timezone"))
if err != nil {
log.Fatalf("failed to load timezone: %v", err)
}
time.Local = loc
}