package main

import (
	"context"
	"log"
	"os"
	"os/signal"
	"syscall"
	"weatherstation/internal/radar"
	"weatherstation/internal/rain"
	"weatherstation/internal/server"
)

func main() {
	server.SetupLogger()

	ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
	defer stop()

	// Start radar scheduler with defaults (StoreToDB=true; tile defaults read inside package)
	if err := radar.Start(ctx, radar.Options{StoreToDB: true}); err != nil {
		log.Fatalf("service-radar start error: %v", err)
	}

	// Also start CMPA hourly rain scheduler (StoreToDB=true; tiles/dir/url from env inside package)
	if err := rain.Start(ctx, rain.Options{StoreToDB: true}); err != nil {
		log.Fatalf("service-rain (embedded) start error: %v", err)
	}

	// Keep process alive until signal
	<-ctx.Done()
	log.Println("service-radar shutting down")
}
