Browse Source

Make DB path configurable

master
Kenneth Bruen 11 months ago
parent
commit
69a0cf3a01
Signed by: kbruen
GPG Key ID: C1980A470C3EE5B1
  1. 8
      main.go

8
main.go

@ -59,7 +59,13 @@ func main() {
log.Fatal("ERROR: No bot token supplied; supply with CFR_BOT.TOKEN") log.Fatal("ERROR: No bot token supplied; supply with CFR_BOT.TOKEN")
} }
db, err := gorm.Open(sqlite.Open("bot_db.sqlite"), &gorm.Config{}) dbPath := os.Getenv("CFR_BOT.DB_PATH")
dbPath = strings.TrimSpace(dbPath)
if len(dbPath) == 0 {
dbPath = "bot_db.sqlite"
}
log.Printf("INFO : DB Path: %s\n", dbPath)
db, err := gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
if err != nil { if err != nil {
panic(err) panic(err)
} }

Loading…
Cancel
Save