backend barebone done, big chunk of work done
CI / Go (build + vet + test) (push) Canceled after 0s
CI / Web (build + lint) (push) Canceled after 0s

This commit is contained in:
vantablackTea
2026-09-27 19:42:49 +03:00
parent 1a669c948a
commit c79a3cfe68
36 changed files with 2607 additions and 17 deletions
+26 -4
View File
@@ -13,9 +13,14 @@ import (
"syscall"
"time"
"messenger/internal/auth"
"messenger/internal/platform/config"
"messenger/internal/platform/logger"
"messenger/internal/realtime"
"messenger/internal/server"
"messenger/internal/store"
"github.com/jackc/pgx/v5/pgxpool"
)
func main() {
@@ -27,7 +32,27 @@ func main() {
os.Exit(1)
}
httpServer := server.New(cfg, log)
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
pool, err := pgxpool.New(ctx, cfg.DatabaseURL)
if err != nil {
log.Error("failed to create db pool", "error", err)
os.Exit(1)
}
defer pool.Close()
st := store.New(pool)
if err := st.Migrate(ctx); err != nil {
log.Error("database migration failed", "error", err)
os.Exit(1)
}
log.Info("database ready")
tm := auth.NewTokenManager(cfg.JWTSecret)
hub := realtime.NewHub(st)
httpServer := server.New(cfg, log, st, tm, hub)
// Run the server in a goroutine so that shutdown can be triggered
// from the signal handler below.
@@ -44,9 +69,6 @@ func main() {
}()
// Wait for a termination signal, then drain in-flight requests.
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
<-ctx.Done()
log.Info("shutting down")