feat: add foundation layer (Go module, config, database, Docker)
Squashed commits from foundation-layer branch: - Initialize Go module and project skeleton (cmd/naviwatcher/main.go) - Add configuration management with YAML parsing and validation - Add database layer with schema migrations (artist_settings, external_releases, notifications_sent) - Add CRUD operations for artist_settings, external_releases, notifications_sent - Add Docker setup with multi-stage build and docker-compose - Verify acceptance criteria (tests, vet, fmt) - Update README.md with build/run/test instructions - Fix: filter ignored releases in GetUnnotifiedReleases (spec compliance) - Fix: add FK constraint on notifications_sent.rgid - Fix: add config.yaml to .gitignore (security) - Fix: run Docker container as non-root user - Fix: pin alpine:3.21 instead of alpine:latest - Fix: wrap migrations in transactions for atomicity All 49 tests pass, go vet clean, Docker image builds successfully.
This commit is contained in:
54
cmd/naviwatcher/main.go
Normal file
54
cmd/naviwatcher/main.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"naviwatcher/internal/config"
|
||||
)
|
||||
|
||||
const defaultConfigPath = "config.yaml"
|
||||
|
||||
func main() {
|
||||
configPath := flag.String("config", defaultConfigPath, "Path to config file")
|
||||
flag.Parse()
|
||||
|
||||
log.Println("NaviWatcher starting...")
|
||||
|
||||
cfg, err := config.LoadConfig(*configPath)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to load config: %v", err)
|
||||
}
|
||||
|
||||
log.Printf("Config loaded from %s (server: %s:%d)", *configPath, cfg.Server.Host, cfg.Server.Port)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
sigCh := make(chan os.Signal, 1)
|
||||
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
sig := <-sigCh
|
||||
log.Printf("Received signal %v, shutting down...", sig)
|
||||
cancel()
|
||||
}()
|
||||
|
||||
if err := run(ctx, cfg); err != nil {
|
||||
log.Fatalf("Application error: %v", err)
|
||||
}
|
||||
|
||||
log.Println("NaviWatcher stopped.")
|
||||
}
|
||||
|
||||
func run(ctx context.Context, cfg *config.Config) error {
|
||||
// Main application loop — blocks until context is cancelled.
|
||||
// Business logic will be added in future tasks.
|
||||
<-ctx.Done()
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user