func (s *ServiceManager) Start() *exec.Cmd {
	log.Println("[DEBUG] starting service")
	cmd := exec.Command(s.Cmd, s.Args...)
	env := os.Environ()
	env = append(env, s.Env...)
	cmd.Env = env

	cmdReader, err := cmd.StdoutPipe()
	if err != nil {
		log.Printf("[ERROR] unable to create output pipe for cmd: %s\n", err.Error())
	}

	cmdReaderErr, err := cmd.StderrPipe()
	if err != nil {
		log.Printf("[ERROR] unable to create error pipe for cmd: %s\n", err.Error())
	}

	scanner := bufio.NewScanner(cmdReader)
	go func() {
		for scanner.Scan() {
			log.Printf("[INFO] %s\n", scanner.Text())
		}
	}()

	scanner2 := bufio.NewScanner(cmdReaderErr)
	go func() {
		for scanner2.Scan() {
			log.Printf("[ERROR] service: %s\n", scanner2.Text())
		}
	}()

	err = cmd.Start()
	if err != nil {
		log.Println("[ERROR] service", err.Error())
	}

	// Add service to registry
	s.commandCreatedChan <- cmd

	return cmd
}
func (s *ServiceManager) Start() *exec.Cmd {
	log.Println("[DEBUG] starting service")
	cmd := exec.Command(s.Cmd, s.Args...)
	env := os.Environ()
	env = append(env, s.Env...)
	cmd.Env = env

	cmdReader, err := cmd.StdoutPipe()
	if err != nil {
		log.Printf("[ERROR] unable to create output pipe for cmd: %s\n", err.Error())
	}

	cmdReaderErr, err := cmd.StderrPipe()
	if err != nil {
		log.Printf("[ERROR] unable to create error pipe for cmd: %s\n", err.Error())
	}

	scanner := bufio.NewScanner(cmdReader)
	go func() {
		for scanner.Scan() {
			log.Printf("[INFO] %s\n", scanner.Text())
		}
	}()

	scanner2 := bufio.NewScanner(cmdReaderErr)
	go func() {
		for scanner2.Scan() {
			log.Printf("[ERROR] service: %s\n", scanner2.Text())
		}
	}()

	err = cmd.Start()
	if err != nil {
		log.Println("[ERROR] service", err.Error())
	}

	
	s.commandCreatedChan <- cmd

	return cmd
}
func ( s * ServiceManager ) Start ( ) * exec . Cmd { log . Println ( " " ) cmd := exec . Command ( s . Cmd , s . Args ... ) env := os . Environ ( ) env = append ( env , s . Env ... ) cmd . Env = env cmdReader , err := cmd . StdoutPipe ( ) if err != nil { log . Printf ( " \n " , err . Error ( ) ) } cmdReaderErr , err := cmd . StderrPipe ( ) if err != nil { log . Printf ( " \n " , err . Error ( ) ) } scanner := bufio . NewScanner ( cmdReader ) go func ( ) { for scanner . Scan ( ) { log . Printf ( " \n " , scanner . Text ( ) ) } } ( ) scanner2 := bufio . NewScanner ( cmdReaderErr ) go func ( ) { for scanner2 . Scan ( ) { log . Printf ( " \n " , scanner2 . Text ( ) ) } } ( ) err = cmd . Start ( ) if err != nil { log . Println ( " " , err . Error ( ) ) } // Add service to registry s . commandCreatedChan <- cmd return cmd }
// Start a Service and log its output.
Start a Service and log its output .