func StartAgent()

in util/common/agent_util_windows.go [49:71]


func StartAgent(configOutputPath string, fatalOnFailure bool, ssm bool) error {
	// @TODO add ssm functionality

	ps, err := exec.LookPath("powershell.exe")

	if err != nil {
		return err
	}

	bashArgs := append([]string{"-NoProfile", "-NonInteractive", "& \"C:\\Program Files\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1\" -a fetch-config -m ec2 -s -c file:" + configOutputPath})
	out, err := exec.Command(ps, bashArgs...).Output()

	if err != nil && fatalOnFailure {
		log.Printf("Start agent failed: %v; the output is: %s", err, string(out))
		return err
	} else if err != nil {
		log.Printf(fmt.Sprint(err) + string(out))
	} else {
		log.Printf("Agent has started")
	}

	return err
}