From b48b03155dc6fac71b33c11f190662addbeaff25 Mon Sep 17 00:00:00 2001 From: Patrick Pfeiffer Date: Thu, 26 Sep 2024 10:54:48 +0200 Subject: [PATCH] fix(userservice): init db for reports --- backend/cmd/user_service/main.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/backend/cmd/user_service/main.go b/backend/cmd/user_service/main.go index 79ba47060..76e634dda 100644 --- a/backend/cmd/user_service/main.go +++ b/backend/cmd/user_service/main.go @@ -93,6 +93,30 @@ func Run() { }, "pgx", "postgres") }() + wg.Add(1) + go func() { + defer wg.Done() + db.WriterDb, db.ReaderDb = db.MustInitDB(&types.DatabaseConfig{ + Username: utils.Config.WriterDatabase.Username, + Password: utils.Config.WriterDatabase.Password, + Name: utils.Config.WriterDatabase.Name, + Host: utils.Config.WriterDatabase.Host, + Port: utils.Config.WriterDatabase.Port, + MaxOpenConns: utils.Config.WriterDatabase.MaxOpenConns, + MaxIdleConns: utils.Config.WriterDatabase.MaxIdleConns, + SSL: utils.Config.WriterDatabase.SSL, + }, &types.DatabaseConfig{ + Username: utils.Config.ReaderDatabase.Username, + Password: utils.Config.ReaderDatabase.Password, + Name: utils.Config.ReaderDatabase.Name, + Host: utils.Config.ReaderDatabase.Host, + Port: utils.Config.ReaderDatabase.Port, + MaxOpenConns: utils.Config.ReaderDatabase.MaxOpenConns, + MaxIdleConns: utils.Config.ReaderDatabase.MaxIdleConns, + SSL: utils.Config.ReaderDatabase.SSL, + }, "pgx", "postgres") + }() + // if needed, init the database, cache or bigtable wg.Wait()