e8f48c6d37
Remove standalone lease-recovery, received-inspection, and result-recovery workers from tenant-api (now handled by scheduler process). Add configurable concurrency to ingest and projection-rebuild workers via MonitoringWorkers runtime config. Extract shared runtime types for worker configuration. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
54 lines
1.4 KiB
Go
54 lines
1.4 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()
|
|
|
|
app.GenerationStreams.Run(workerCtx)
|
|
|
|
monitoringCallbackService := tenantapp.NewMonitoringCallbackService(app.DB, app.MonitoringDB, app.RabbitMQ, app.LLM, app.Logger)
|
|
tenantapp.NewMonitoringResultIngestWorker(monitoringCallbackService, app.RabbitMQ, app.Logger, app.Config.MonitoringWorkers).Start(workerCtx)
|
|
tenantapp.NewMonitoringProjectionRebuildWorker(monitoringCallbackService, app.RabbitMQ, app.Logger, app.Config.MonitoringWorkers).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...")
|
|
}
|