From d827debd7f118d09eb728a4ab6b568207c5eae7c Mon Sep 17 00:00:00 2001 From: nquidox Date: Mon, 23 Feb 2026 18:34:38 +0300 Subject: [PATCH] minimal app --- cmd/main.go | 23 ++++++++++++++++++++++- internal/app/handler.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 internal/app/handler.go diff --git a/cmd/main.go b/cmd/main.go index 38dd16d..c6971e5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,3 +1,24 @@ package main -func main() {} +import ( + "context" + log "github.com/sirupsen/logrus" + "merch-api/config" + "merch-api/internal/app" + "os" + "os/signal" + "syscall" +) + +func main() { + ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + defer cancel() + + cfg := config.NewConfig() + + appl := app.New(cfg) + + if err := appl.Run(ctx); err != nil { + log.Fatal(err) + } +} diff --git a/internal/app/handler.go b/internal/app/handler.go new file mode 100644 index 0000000..c8a8478 --- /dev/null +++ b/internal/app/handler.go @@ -0,0 +1,29 @@ +package app + +import ( + "context" + log "github.com/sirupsen/logrus" + "merch-api/config" +) + +type App struct { + cfg config.Config +} + +func New(cfg config.Config) *App { + return &App{cfg: cfg} +} + +func (app *App) Run(ctx context.Context) error { + log.Info("Starting application...") + select { + case <-ctx.Done(): + app.Shutdown(ctx) + } + return nil +} + +func (app *App) Shutdown(ctx context.Context) { + log.Info("Shutting down application...") + return +}