add config ssl file check
This commit is contained in:
parent
c1f0ae6b9b
commit
45c8fc4f0e
12
main.go
12
main.go
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"dorisbot/pkg/config"
|
||||
"dorisbot/pkg/options"
|
||||
"dorisbot/pkg/svc/discord"
|
||||
"fmt"
|
||||
@ -12,6 +13,7 @@ func init() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
opts := options.GetOptions()
|
||||
if opts.Help {
|
||||
opts.ShowUsage()
|
||||
@ -20,9 +22,15 @@ func main() {
|
||||
|
||||
fmt.Println("Bot Svc")
|
||||
cc := make(chan bool)
|
||||
botToken := "NDEyNTEzNzk2OTA1NTAwNjcy.XQ-Shw.sS-Ldtu1fgCaPPNG_Bn3i0LX2wg"
|
||||
|
||||
client, err := discord.NewClient(botToken)
|
||||
err = config.LoadConfig(opts.Config)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
conf := config.GetConfig()
|
||||
|
||||
client, err := discord.NewClient(conf.Discord.BotToken)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -76,5 +76,17 @@ func LoadConfig(p ...string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if exists := utils.CheckExists(conf.Database.SSLCa, false); !exists {
|
||||
return errors.New("ssl ca file not exists")
|
||||
}
|
||||
|
||||
if exists := utils.CheckExists(conf.Database.SSLCrt, false); !exists {
|
||||
return errors.New("ssl crt file not exists")
|
||||
}
|
||||
|
||||
if exists := utils.CheckExists(conf.Database.SSLKey, false); !exists {
|
||||
return errors.New("ssl key file not exists")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user