Files
OpenList/bootstrap/config.go

32 lines
747 B
Go
Raw Normal View History

2020-12-24 01:39:45 +08:00
package bootstrap
import (
"github.com/Xhofe/alist/conf"
"github.com/Xhofe/alist/utils"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
"io/ioutil"
2021-01-08 16:32:02 +08:00
"strings"
2020-12-24 01:39:45 +08:00
)
2021-02-04 10:02:34 +08:00
// read config file
2020-12-24 01:39:45 +08:00
func ReadConf(config string) bool {
2020-12-26 18:11:17 +08:00
log.Infof("读取配置文件...")
2020-12-24 01:39:45 +08:00
if !utils.Exists(config) {
log.Infof("找不到配置文件:%s",config)
return false
}
confFile,err:=ioutil.ReadFile(config)
if err !=nil {
log.Errorf("读取配置文件时发生错误:%s",err.Error())
return false
}
err = yaml.Unmarshal(confFile, conf.Conf)
if err !=nil {
log.Errorf("加载配置文件时发生错误:%s",err.Error())
return false
}
2020-12-31 15:03:25 +08:00
log.Debugf("config:%+v",conf.Conf)
2021-01-11 16:53:48 +08:00
conf.Origins = strings.Split(conf.Conf.Server.SiteUrl,",")
2020-12-24 01:39:45 +08:00
return true
}