feat: bootstrap foundation application

This commit is contained in:
2026-04-29 00:26:58 -04:00
parent 8e6646499f
commit 4a72e1e030
53 changed files with 4443 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
package main
import (
"context"
"errors"
"log/slog"
"net/http"
"os"
"os/signal"
"syscall"
"github.com/tim/md-hub-secure/apps/server/internal/app"
"github.com/tim/md-hub-secure/apps/server/internal/config"
"github.com/tim/md-hub-secure/apps/server/internal/logging"
)
func main() {
cfg, err := config.Load()
if err != nil {
slog.Error("load config", "error", err)
os.Exit(1)
}
logger := logging.New(cfg.LogLevel)
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
application, err := app.New(ctx, cfg, logger)
if err != nil {
logger.Error("initialize application", "error", err)
os.Exit(1)
}
defer func() {
if closeErr := application.Close(); closeErr != nil {
logger.Error("close application", "error", closeErr)
}
}()
err = application.Run(ctx)
if err != nil && !errors.Is(err, http.ErrServerClosed) {
logger.Error("run application", "error", err)
os.Exit(1)
}
}