github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/cli/agent_windows.go (about) 1 package cli 2 3 import ( 4 "fmt" 5 6 "github.com/kardianos/service" 7 "github.com/pyroscope-io/pyroscope/pkg/config" 8 ) 9 10 func StartAgent(config *config.Agent) error { 11 logger, err := createLogger(config) 12 if err != nil { 13 return fmt.Errorf("could not create logger: %w", err) 14 } 15 if err = loadAgentConfig(config); err != nil { 16 return fmt.Errorf("could not load targets: %w", err) 17 } 18 logger.Info("starting pyroscope agent") 19 agent, err := newAgentService(logger, config) 20 if err != nil { 21 return fmt.Errorf("could not initialize agent: %w", err) 22 } 23 svc, err := service.New(agent, &service.Config{Name: "pyroscope"}) 24 if err != nil { 25 return fmt.Errorf("could not initialize system service: %w", err) 26 } 27 return svc.Run() 28 }