agent

package
v0.38.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "agent",
	Short: "Agent.",
	Long:  `Sidecar agent for Galera that co-operates with mariadb-operator.`,
	Args:  cobra.NoArgs,
	Run: func(cmd *cobra.Command, args []string) {
		if err := log.SetupLoggerWithCommand(cmd); err != nil {
			fmt.Printf("error setting up logger: %v\n", err)
			os.Exit(1)
		}
		logger.Info("Agent starting")

		env, err := environment.GetPodEnv(context.Background())
		if err != nil {
			logger.Error(err, "Error getting environment variables")
			os.Exit(1)
		}
		fileManager, err := filemanager.NewFileManager(configDir, stateDir)
		if err != nil {
			logger.Error(err, "Error creating file manager")
			os.Exit(1)
		}
		state := state.NewState(stateDir)
		k8sClient, err := getK8sClient()
		if err != nil {
			logger.Error(err, "Error getting Kubernetes client")
			os.Exit(1)
		}

		apiServer, err := getAPIServer(
			env,
			fileManager,
			k8sClient,
			state,
			logger,
		)
		if err != nil {
			logger.Error(err, "Error creating API server")
			os.Exit(1)
		}
		probeServer, err := getProbeServer(env, k8sClient)
		if err != nil {
			logger.Error(err, "Error creating probe server")
			os.Exit(1)
		}

		ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
		defer cancel()
		errChan := make(chan error, 2)

		var wg sync.WaitGroup
		wg.Add(2)
		go func() {
			defer wg.Done()

			if err := apiServer.Start(ctx); err != nil {
				errChan <- fmt.Errorf("error starting API server: %v", err)
			}
		}()
		go func() {
			defer wg.Done()

			if err := probeServer.Start(ctx); err != nil {
				errChan <- fmt.Errorf("error starting probe server: %v", err)
			}
		}()
		go func() {
			wg.Wait()
			close(errChan)
		}()

		if err, ok := <-errChan; ok {
			logger.Error(err, "Server error")
			os.Exit(1)
		}
		logger.Info("Agent stopped")
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy