6066f43a7d
- Implement monitoring service with heartbeat, lease tasks, resume tasks, and task result handling. - Create monitoring time utilities for business date calculations. - Add unit tests for date window resolution and business day handling. - Define database schema for monitoring-related tables including quotas, daily reports, and task management. - Establish migration scripts for creating and dropping monitoring tables.
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/geo-platform/tenant-api/internal/bootstrap"
|
|
tenantapp "github.com/geo-platform/tenant-api/internal/tenant/app"
|
|
"github.com/geo-platform/tenant-api/internal/tenant/transport"
|
|
)
|
|
|
|
func main() {
|
|
configPath := "configs/config.yaml"
|
|
if p := os.Getenv("CONFIG_PATH"); p != "" {
|
|
configPath = p
|
|
}
|
|
|
|
app, err := bootstrap.New(configPath)
|
|
if err != nil {
|
|
log.Fatalf("bootstrap: %v", err)
|
|
}
|
|
defer app.Close()
|
|
|
|
workerCtx, workerCancel := context.WithCancel(context.Background())
|
|
defer workerCancel()
|
|
|
|
monitoringCallbackService := tenantapp.NewMonitoringCallbackService(app.DB, app.MonitoringDB, app.RabbitMQ, app.LLM, app.Logger)
|
|
tenantapp.NewMonitoringResultIngestWorker(monitoringCallbackService, app.RabbitMQ, app.Logger).Start(workerCtx)
|
|
tenantapp.NewMonitoringProjectionRebuildWorker(monitoringCallbackService, app.RabbitMQ, app.Logger).Start(workerCtx)
|
|
tenantapp.NewMonitoringResultRecoveryWorker(app.MonitoringDB, monitoringCallbackService, app.Logger).Start(workerCtx)
|
|
tenantapp.NewMonitoringLeaseRecoveryWorker(app.MonitoringDB, app.Logger).Start(workerCtx)
|
|
tenantapp.NewMonitoringReceivedInspectionWorker(app.MonitoringDB, app.Logger).Start(workerCtx)
|
|
|
|
transport.RegisterRoutes(app)
|
|
|
|
addr := fmt.Sprintf(":%d", app.Config.Server.Port)
|
|
app.Logger.Sugar().Infof("tenant-api starting on %s", addr)
|
|
|
|
go func() {
|
|
if err := app.Engine.Run(addr); err != nil {
|
|
app.Logger.Sugar().Fatalf("server: %v", err)
|
|
}
|
|
}()
|
|
|
|
quit := make(chan os.Signal, 1)
|
|
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
|
<-quit
|
|
workerCancel()
|
|
app.Logger.Info("shutting down...")
|
|
}
|