add config
This commit is contained in:
@@ -52,7 +52,7 @@ func GetMonthFromLocalized(month string) (int, error) {
|
||||
case "december":
|
||||
return 12, nil
|
||||
default:
|
||||
return 0, fmt.Errorf("Month not recognized %1", month)
|
||||
return 0, fmt.Errorf("month not recognized %s", month)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ func RunElevatedCommand(command string, service string) (string, error) {
|
||||
cmd := exec.Command("powershell", "-nologo", "-noprofile", "-File", "run_sc.ps1", command, service)
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
log.Panic("error: %v, output: %s", err, string(output))
|
||||
log.Panicf("error: %v, output: %s", err, string(output))
|
||||
return "", fmt.Errorf("error: %v, output: %s", err, string(output))
|
||||
}
|
||||
return string(output), nil
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"rockhu-bot/local/model"
|
||||
"time"
|
||||
@@ -11,8 +12,9 @@ import (
|
||||
)
|
||||
|
||||
func Start(di *dig.Container) {
|
||||
dbConn := os.Getenv("DB_CONNECTION")
|
||||
db, err := gorm.Open(postgres.New(postgres.Config{
|
||||
DSN: os.Getenv("CONNECTION_STRINGS"),
|
||||
DSN: dbConn,
|
||||
PreferSimpleProtocol: true,
|
||||
}), &gorm.Config{
|
||||
NowFunc: func() time.Time {
|
||||
@@ -20,13 +22,13 @@ func Start(di *dig.Container) {
|
||||
return time.Now().In(utc)
|
||||
}})
|
||||
if err != nil {
|
||||
panic("failed to connect database")
|
||||
log.Panic("failed to connect database")
|
||||
}
|
||||
err = di.Provide(func() *gorm.DB {
|
||||
return db
|
||||
})
|
||||
if err != nil {
|
||||
panic("failed to bind database")
|
||||
log.Panic("failed to bind database")
|
||||
}
|
||||
Migrate(db)
|
||||
}
|
||||
@@ -34,6 +36,6 @@ func Start(di *dig.Container) {
|
||||
func Migrate(db *gorm.DB) {
|
||||
err := db.AutoMigrate(&model.ConcertModel{})
|
||||
if err != nil {
|
||||
panic("failed to migrate model.ApiModel")
|
||||
log.Panic("failed to migrate model.ApiModel")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package discordrhu
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
@@ -10,6 +11,9 @@ import (
|
||||
|
||||
func Init(di *dig.Container) {
|
||||
dsc, err := discordgo.New("Bot " + os.Getenv("DISCORD_KEY"))
|
||||
dsc.AddHandler(func(s *discordgo.Session, r *discordgo.Ready) {
|
||||
fmt.Println("Bot is ready")
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Panic("unable to start discord session!")
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"rockhu-bot/local/api"
|
||||
"rockhu-bot/local/utl/common"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"rockhu-bot/local/api"
|
||||
"rockhu-bot/local/utl/common"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/cors"
|
||||
|
||||
Reference in New Issue
Block a user