2023-04-06 10:36:11 +05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-07-22 11:33:14 +05:00
|
|
|
"github.com/ordinary-dev/phoenix/config"
|
2023-07-22 15:24:01 +05:00
|
|
|
"github.com/ordinary-dev/phoenix/database"
|
2023-04-06 10:36:11 +05:00
|
|
|
"github.com/ordinary-dev/phoenix/views"
|
2023-07-22 11:33:14 +05:00
|
|
|
"github.com/sirupsen/logrus"
|
2023-04-06 10:36:11 +05:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2023-07-22 11:33:14 +05:00
|
|
|
// Configure logger
|
|
|
|
logrus.SetFormatter(&logrus.TextFormatter{
|
|
|
|
FullTimestamp: true,
|
|
|
|
})
|
|
|
|
|
|
|
|
// Read config
|
|
|
|
cfg, err := config.GetConfig()
|
|
|
|
if err != nil {
|
|
|
|
logrus.Fatalf("%v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set log level
|
|
|
|
logLevel := cfg.GetLogLevel()
|
|
|
|
logrus.SetLevel(logLevel)
|
|
|
|
logrus.Infof("Setting log level to %v", logLevel)
|
|
|
|
|
|
|
|
// Connect to the database
|
2023-07-22 15:24:01 +05:00
|
|
|
db, err := database.GetDatabaseConnection(cfg)
|
2023-04-06 10:36:11 +05:00
|
|
|
if err != nil {
|
2023-07-22 11:33:14 +05:00
|
|
|
logrus.Fatalf("%v", err)
|
2023-04-06 10:36:11 +05:00
|
|
|
}
|
|
|
|
|
2023-07-22 15:19:04 +05:00
|
|
|
engine := views.GetGinEngine(cfg, db)
|
|
|
|
engine.Run(":8080")
|
2023-04-06 10:36:11 +05:00
|
|
|
}
|