in cmd/ops_agent_windows/main_windows.go [91:154]
func initServices() error {
// Identify relevant paths
self, err := osext.Executable()
if err != nil {
return fmt.Errorf("could not determine own path: %w", err)
}
base, err := osext.ExecutableFolder()
if err != nil {
return fmt.Errorf("could not determine binary path: %w", err)
}
configOutDir := filepath.Join(os.Getenv("PROGRAMDATA"), dataDirectory, "generated_configs")
if err := os.MkdirAll(configOutDir, 0644); err != nil {
return err
}
fluentbitStoragePath := filepath.Join(os.Getenv("PROGRAMDATA"), dataDirectory, `run\buffers`)
if err := os.MkdirAll(fluentbitStoragePath, 0644); err != nil {
return err
}
logDirectory := filepath.Join(os.Getenv("PROGRAMDATA"), dataDirectory, "log")
if err := os.MkdirAll(logDirectory, 0644); err != nil {
return err
}
// TODO: Write meaningful descriptions for these services
services = []struct {
name string
displayName string
exepath string
args []string
}{
{
serviceName,
serviceDisplayName,
self,
[]string{
"-in", filepath.Join(base, "../config/config.yaml"),
"-out", configOutDir,
},
},
{
fmt.Sprintf("%s-opentelemetry-collector", serviceName),
fmt.Sprintf("%s - Metrics Agent", serviceDisplayName),
filepath.Join(base, "google-cloud-metrics-agent_windows_amd64.exe"),
[]string{
"--config=" + filepath.Join(configOutDir, `otel\otel.yaml`),
},
},
{
// TODO: fluent-bit hardcodes a service name of "fluent-bit"; do we need to match that?
fmt.Sprintf("%s-fluent-bit", serviceName),
fmt.Sprintf("%s - Logging Agent", serviceDisplayName),
filepath.Join(base, fmt.Sprintf("%s-wrapper.exe", serviceName)),
[]string{
"-log_path", filepath.Join(logDirectory, "logging-module.log"),
"-config_path", filepath.Join(base, "../config/config.yaml"),
filepath.Join(base, "fluent-bit.exe"),
"-c", filepath.Join(configOutDir, `fluentbit\fluent_bit_main.conf`),
"-R", filepath.Join(configOutDir, `fluentbit\fluent_bit_parser.conf`),
"--storage_path", fluentbitStoragePath,
},
},
}
return nil
}