buildr/main.go
Peter 3de7016a50
All checks were successful
continuous-integration/drone/push Build is passing
refactor: make init logic more lazy and less verbose
- implement most services that need further initialization as lazy.Lazy
- make config structure less dynamic and more explicit - it's always .buildr for the configs
2023-09-22 22:35:57 +02:00

36 lines
641 B
Go

package main
import (
"context"
"errors"
"log/slog"
"os"
"os/signal"
"code.icb4dc0.de/buildr/buildr/internal/cmd"
"code.icb4dc0.de/buildr/buildr/internal/errs"
)
func main() {
slogOptions := slog.HandlerOptions{
AddSource: true,
Level: slog.LevelInfo,
}
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, &slogOptions)))
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, os.Kill)
app := cmd.NewApp(ctx)
if err := app.Run(ctx); err != nil {
if !errors.Is(err, errs.ErrAlreadyLogged) {
slog.Error("Error occurred", slog.Any("error", err))
}
cancel()
os.Exit(1)
}
cancel()
}