refactor: update worker processes in EvoBGP to accept dependencies for shared store and job registry. Enhance scheduler, ingest, render, and deploy components to utilize a unified context and improve logging for drift detection. Update architecture documentation to reflect changes in process interactions and worker functionalities.
This commit is contained in:
@@ -21,7 +21,7 @@ import (
|
||||
"evobgp/internal/scheduler"
|
||||
)
|
||||
|
||||
// microVPS entrypoint: one process — HTTP API (same as evobgp-api) plus in-process stubs for scheduler/ingest/render/deploy.
|
||||
// microVPS entrypoint: one process — HTTP API plus in-process scheduler, ingest, render, deploy workers (shared store + job registry).
|
||||
func main() {
|
||||
cfg := config.Load()
|
||||
opts := httpapi.Options{
|
||||
@@ -42,10 +42,14 @@ func main() {
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
|
||||
go scheduler.Run(ctx)
|
||||
go ingest.Run(ctx)
|
||||
go render.Run(ctx)
|
||||
go deploy.Run(ctx)
|
||||
schedDeps := &scheduler.Deps{Store: srv.Store(), Jobs: srv.Jobs()}
|
||||
ingestDeps := &ingest.Deps{Store: srv.Store()}
|
||||
renderDeps := &render.Deps{Store: srv.Store()}
|
||||
deployDeps := &deploy.Deps{Store: srv.Store()}
|
||||
go scheduler.Run(ctx, schedDeps)
|
||||
go ingest.Run(ctx, ingestDeps)
|
||||
go render.Run(ctx, renderDeps)
|
||||
go deploy.Run(ctx, deployDeps)
|
||||
|
||||
startBirdMetricsPoller()
|
||||
|
||||
|
||||
@@ -5,10 +5,13 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"evobgp/internal/config"
|
||||
"evobgp/internal/deploy"
|
||||
"evobgp/internal/httpapi"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -20,5 +23,20 @@ func main() {
|
||||
log.Printf("%s starting (reference profile worker)", name)
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
deploy.Run(ctx)
|
||||
|
||||
bctx, bcancel := context.WithTimeout(context.Background(), 90*time.Second)
|
||||
defer bcancel()
|
||||
opts := httpapi.Options{
|
||||
DatabaseURL: strings.TrimSpace(os.Getenv("EVOBGP_DATABASE_URL")),
|
||||
SeedDemo: os.Getenv("EVOBGP_SEED_DEMO") != "0",
|
||||
}
|
||||
st, _, pool, err := httpapi.BootstrapWorkers(bctx, opts)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if pool != nil {
|
||||
defer pool.Close()
|
||||
}
|
||||
|
||||
deploy.Run(ctx, &deploy.Deps{Store: st})
|
||||
}
|
||||
|
||||
@@ -5,9 +5,12 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"evobgp/internal/config"
|
||||
"evobgp/internal/httpapi"
|
||||
"evobgp/internal/ingest"
|
||||
)
|
||||
|
||||
@@ -20,5 +23,20 @@ func main() {
|
||||
log.Printf("%s starting (reference profile worker)", name)
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
ingest.Run(ctx)
|
||||
|
||||
bctx, bcancel := context.WithTimeout(context.Background(), 90*time.Second)
|
||||
defer bcancel()
|
||||
opts := httpapi.Options{
|
||||
DatabaseURL: strings.TrimSpace(os.Getenv("EVOBGP_DATABASE_URL")),
|
||||
SeedDemo: os.Getenv("EVOBGP_SEED_DEMO") != "0",
|
||||
}
|
||||
st, _, pool, err := httpapi.BootstrapWorkers(bctx, opts)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if pool != nil {
|
||||
defer pool.Close()
|
||||
}
|
||||
|
||||
ingest.Run(ctx, &ingest.Deps{Store: st})
|
||||
}
|
||||
|
||||
@@ -5,9 +5,12 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"evobgp/internal/config"
|
||||
"evobgp/internal/httpapi"
|
||||
"evobgp/internal/render"
|
||||
)
|
||||
|
||||
@@ -20,5 +23,20 @@ func main() {
|
||||
log.Printf("%s starting (reference profile worker)", name)
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
render.Run(ctx)
|
||||
|
||||
bctx, bcancel := context.WithTimeout(context.Background(), 90*time.Second)
|
||||
defer bcancel()
|
||||
opts := httpapi.Options{
|
||||
DatabaseURL: strings.TrimSpace(os.Getenv("EVOBGP_DATABASE_URL")),
|
||||
SeedDemo: os.Getenv("EVOBGP_SEED_DEMO") != "0",
|
||||
}
|
||||
st, _, pool, err := httpapi.BootstrapWorkers(bctx, opts)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if pool != nil {
|
||||
defer pool.Close()
|
||||
}
|
||||
|
||||
render.Run(ctx, &render.Deps{Store: st})
|
||||
}
|
||||
|
||||
@@ -3,11 +3,15 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"evobgp/internal/config"
|
||||
"evobgp/internal/httpapi"
|
||||
"evobgp/internal/scheduler"
|
||||
)
|
||||
|
||||
@@ -20,5 +24,34 @@ func main() {
|
||||
log.Printf("%s starting (reference profile worker)", name)
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
scheduler.Run(ctx)
|
||||
|
||||
bctx, bcancel := context.WithTimeout(context.Background(), 90*time.Second)
|
||||
defer bcancel()
|
||||
opts := httpapi.Options{
|
||||
DatabaseURL: strings.TrimSpace(os.Getenv("EVOBGP_DATABASE_URL")),
|
||||
SeedDemo: os.Getenv("EVOBGP_SEED_DEMO") != "0",
|
||||
}
|
||||
st, reg, pool, err := httpapi.BootstrapWorkers(bctx, opts)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if pool != nil {
|
||||
defer pool.Close()
|
||||
}
|
||||
|
||||
apiBase := strings.TrimSpace(os.Getenv("EVOBGP_CONTROL_PLANE_URL"))
|
||||
apiTok := strings.TrimSpace(os.Getenv("EVOBGP_SCHEDULER_BEARER"))
|
||||
deps := &scheduler.Deps{
|
||||
Store: st,
|
||||
HTTP: &http.Client{Timeout: 45 * time.Second},
|
||||
}
|
||||
if apiBase != "" && apiTok != "" {
|
||||
deps.APIBase = apiBase
|
||||
deps.APIToken = apiTok
|
||||
log.Printf("evobgp-scheduler: control plane HTTP mode (%s)", apiBase)
|
||||
} else {
|
||||
deps.Jobs = reg
|
||||
log.Printf("evobgp-scheduler: in-process job registry mode (use EVOBGP_CONTROL_PLANE_URL + EVOBGP_SCHEDULER_BEARER for split containers)")
|
||||
}
|
||||
scheduler.Run(ctx, deps)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user