Make SCUM logs live relay only
This commit is contained in:
@@ -30,6 +30,8 @@ func main() {
|
||||
trajectoryStatus := &companion.TrajectoryCollectionStatus{}
|
||||
collector, cleanup := buildTrajectoryCollector(config, trajectoryStatus)
|
||||
defer cleanup()
|
||||
consoleCollector, consoleCleanup := buildConsoleLogCollector(config, client)
|
||||
defer consoleCleanup()
|
||||
|
||||
registry := companion.NewHandlerRegistry(defaultHandlerAvailability(config), companion.RuntimeAdapter{
|
||||
BoundServerID: config.Component.ServerInstanceID,
|
||||
@@ -52,11 +54,14 @@ func main() {
|
||||
Health: trajectoryStatus.HealthReport,
|
||||
}
|
||||
|
||||
errorsCh := make(chan error, 2)
|
||||
errorsCh := make(chan error, 3)
|
||||
go func() { errorsCh <- runtime.Run(ctx) }()
|
||||
if collector != nil {
|
||||
go func() { errorsCh <- collector.Run(ctx, trajectoryStatus) }()
|
||||
}
|
||||
if consoleCollector != nil {
|
||||
go func() { errorsCh <- consoleCollector.Run(ctx) }()
|
||||
}
|
||||
|
||||
err = <-errorsCh
|
||||
stop()
|
||||
@@ -75,6 +80,18 @@ func loadConfig() (companion.Config, error) {
|
||||
return companion.LoadConfig(file)
|
||||
}
|
||||
|
||||
func buildConsoleLogCollector(config companion.Config, client *companion.Client) (*companion.ConsoleLogCollector, func()) {
|
||||
cleanup := func() {}
|
||||
store, err := companion.OpenSCUMSQLStoreFromEnv(companion.PlatformMySQLDSNEnvironment)
|
||||
if err != nil {
|
||||
log.Printf("SCUM companion console log store unavailable: %v", err)
|
||||
return nil, cleanup
|
||||
}
|
||||
cleanup = func() { _ = store.Close() }
|
||||
secret := os.Getenv(config.Proof.MaterialEnv)
|
||||
return companion.NewConsoleLogCollector(client, store, config.Component.ServerInstanceID, secret), cleanup
|
||||
}
|
||||
|
||||
func buildTrajectoryCollector(config companion.Config, status *companion.TrajectoryCollectionStatus) (*companion.TrajectoryCollector, func()) {
|
||||
cleanup := func() {}
|
||||
if !config.Trajectory.Enabled {
|
||||
|
||||
Reference in New Issue
Block a user