40 lines
808 B
Go
40 lines
808 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"git.rouggy.com/rouggy/RaceBot/api"
|
|
"git.rouggy.com/rouggy/RaceBot/config"
|
|
"git.rouggy.com/rouggy/RaceBot/database"
|
|
"git.rouggy.com/rouggy/RaceBot/models"
|
|
"github.com/jinzhu/gorm"
|
|
)
|
|
|
|
func main() {
|
|
|
|
config.Load()
|
|
|
|
database.SQLiteDBConnect()
|
|
defer func(db *gorm.DB) {
|
|
err := db.Close()
|
|
if err != nil {
|
|
fmt.Println("Could not close the database")
|
|
}
|
|
}(database.GetDB())
|
|
|
|
SQLiteMigrate()
|
|
|
|
server := api.NewServer(":" + config.HTTPPort)
|
|
err := server.Start()
|
|
if err != nil {
|
|
fmt.Println("Could not start server")
|
|
}
|
|
}
|
|
|
|
func SQLiteMigrate() {
|
|
db := database.GetDB()
|
|
if err := db.AutoMigrate(&models.Release{}, &models.Race{}).Error; err != nil {
|
|
panic("[Database] Failed migrating database: ")
|
|
}
|
|
fmt.Println("[Database] Database successfully migrated")
|
|
}
|