init
This commit is contained in:
21
app/app.go
21
app/app.go
@@ -42,6 +42,17 @@ func NewApp(cfg *config.Config) *App {
|
||||
// Channel pour les erreurs
|
||||
errChan := make(chan error, 1)
|
||||
|
||||
// database init
|
||||
dbConfig := database.DBConfig{
|
||||
Driver: cfg.Database.Type,
|
||||
DSN: cfg.GetDSN(),
|
||||
}
|
||||
|
||||
// 1) Initialiser la DB
|
||||
if err := database.Initialize(dbConfig); err != nil {
|
||||
//return fmt.Errorf("failed to initialize database: %w", err)
|
||||
}
|
||||
|
||||
// Servers
|
||||
udpServer := udp.NewServer(cfg.Server.BindAddr)
|
||||
httpServer := http.NewServer(cfg.Server.BindAddr)
|
||||
@@ -61,16 +72,6 @@ func (app *App) Run() error {
|
||||
// Context pour gérer l'arrêt gracieux
|
||||
defer app.cancel()
|
||||
|
||||
dbConfig := database.DBConfig{
|
||||
Driver: app.cfg.Database.Type,
|
||||
DSN: app.cfg.GetDSN(),
|
||||
}
|
||||
|
||||
// 1) Initialiser la DB
|
||||
if err := database.Initialize(dbConfig); err != nil {
|
||||
return fmt.Errorf("failed to initialize database: %w", err)
|
||||
}
|
||||
|
||||
// (optionnel) garder une référence locale si tu veux utiliser app.db ailleurs
|
||||
app.db = database.DB
|
||||
|
||||
|
||||
Reference in New Issue
Block a user