- Fix notifications_sent PK: changed from (rgid, sent_at) to rgid-only PK to prevent duplicate RGID rows across seconds. Use INSERT OR REPLACE instead of INSERT OR IGNORE for true idempotency. - Add foreign key constraints to DDL (artist_id references artist_settings, rgid references external_releases) per specification. - Enable PRAGMA foreign_keys=ON and PRAGMA busy_timeout=5000 for concurrent access safety. - Fix GetNotificationSentAt query: add ORDER BY sent_at DESC LIMIT 1 for deterministic results. - Fix config test: change YAML key from 'chat' to 'chat_id' to match struct tag, add ChatID assertion. - Fix migration tracking test: correct error message from "expected 4" to "expected 3". - Remove dead code in TestLoadConfig_InvalidPort: eliminate unused YAML template and remove port 0 case (valid, not invalid). - Remove unused path parameter from buildConfigWithPort helper. - Remove pointless 100ms sleep in run() and unused time import. - Remove tautological TestDefaultConfigPath test. - Update README.md: Go version 1.21+ to 1.25+, placeholder passwords to CHANGE_ME. - Update config.yaml.example: placeholder passwords to CHANGE_ME. - Update all database tests to insert parent rows first for FK satisfaction. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
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
|
|
}
|