func()

in internal/daemon/oracle/oracle.go [59:111]


func (s *Service) Start(ctx context.Context, a any) {
	go (func() {
		for {
			s.checkServiceCommunication(ctx)
		}
	})()
	// Check if the enabled field is unset. If it is, then the service is still enabled if the workload is present.
	if s.Config.GetOracleConfiguration().Enabled == nil {
		log.CtxLogger(ctx).Info("Oracle service enabled field is not set, will check for workload presence to determine if service should be enabled.")
		// If the workload is present, proceed with starting the service even if it is not enabled.
		for !s.isProcessPresent {
			time.Sleep(5 * time.Second)
		}
		log.CtxLogger(ctx).Info("Oracle workload is present. Starting service.")
	} else if !s.Config.GetOracleConfiguration().GetEnabled() {
		log.CtxLogger(ctx).Info("Oracle service is disabled")
		return
	}

	if runtime.GOOS != "linux" {
		log.CtxLogger(ctx).Error("Oracle service is only supported on Linux")
		return
	}

	if s.Config.GetOracleConfiguration().GetOracleDiscovery().GetEnabled() {
		dCtx := log.SetCtx(ctx, "context", "OracleDiscovery")
		s.discoveryRoutine = &recovery.RecoverableRoutine{
			Routine:             runDiscovery,
			RoutineArg:          runDiscoveryArgs{s},
			ErrorCode:           usagemetrics.OracleDiscoverDatabaseFailure,
			UsageLogger:         *usagemetrics.UsageLogger,
			ExpectedMinDuration: 0,
		}
		s.discoveryRoutine.StartRoutine(dCtx)
	}

	if s.Config.GetOracleConfiguration().GetOracleMetrics().GetEnabled() {
		mcCtx := log.SetCtx(ctx, "context", "OracleMetricCollection")
		s.metricCollectionRoutine = &recovery.RecoverableRoutine{
			Routine:             runMetricCollection,
			RoutineArg:          runMetricCollectionArgs{s},
			ErrorCode:           usagemetrics.OracleMetricCollectionFailure,
			UsageLogger:         *usagemetrics.UsageLogger,
			ExpectedMinDuration: 0,
		}
		s.metricCollectionRoutine.StartRoutine(mcCtx)
	}
	select {
	case <-ctx.Done():
		log.CtxLogger(ctx).Info("Oracle workload agent service cancellation requested")
		return
	}
}