Initial phase 1 baseline implementation
This commit is contained in:
parent
099c53badf
commit
077cf7601a
29 changed files with 1339 additions and 39 deletions
|
|
@ -10,7 +10,9 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"drive.local/drivev2/internal/adapters/postgres"
|
||||
"drive.local/drivev2/internal/adapters/webassets"
|
||||
"drive.local/drivev2/internal/application"
|
||||
"drive.local/drivev2/internal/config"
|
||||
"drive.local/drivev2/internal/transport/httpapi"
|
||||
)
|
||||
|
|
@ -46,11 +48,26 @@ func serve() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if cfg.DatabaseURL == "" {
|
||||
return errors.New("DRIVE_DATABASE_URL is required for serve")
|
||||
}
|
||||
|
||||
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: cfg.LogLevel}))
|
||||
slog.SetDefault(logger)
|
||||
|
||||
server := httpapi.NewServer(cfg, version, logger, webassets.New(cfg.WebRoot))
|
||||
startupCtx, startupCancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer startupCancel()
|
||||
if err := postgres.Migrate(cfg.DatabaseURL); err != nil {
|
||||
return err
|
||||
}
|
||||
store, err := postgres.Open(startupCtx, cfg.DatabaseURL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer store.Close()
|
||||
|
||||
systemService := application.NewSystemService(store, version)
|
||||
server := httpapi.NewServer(cfg, logger, systemService, webassets.New(cfg.WebRoot))
|
||||
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||
defer stop()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue