medium.rip/main.go
Sphericalkat 219d16ea19 feat: add shutdown listener
Signed-off-by: Sphericalkat <amolele@gmail.com>
2023-05-26 19:50:40 +05:30

32 lines
511 B
Go

package main
import (
"context"
"sync"
log "github.com/sirupsen/logrus"
"github.com/medium.rip/api"
"github.com/medium.rip/internal/config"
"github.com/medium.rip/internal/lifecycle"
)
func main() {
// load config
config.Load()
// cancellable context
wg := sync.WaitGroup{}
ctx, cancelFunc := context.WithCancel(context.Background())
wg.Add(1)
go api.RegisterRoutes(ctx, &wg)
wg.Add(1)
go lifecycle.ShutdownListener(&wg, &cancelFunc)
wg.Wait()
log.Info("Graceful shutdown complete")
}