Beispiel #1
0
func JobExec(name string, args []string, env map[string]string, streams beam.Streamer, db beam.DB) error {
	var (
		cmdName string
		cmdArgs []string
	)
	if len(args) >= 1 {
		cmdName = args[0]
	} else {
		return fmt.Errorf("Not enough arguments")
	}
	if len(args) > 1 {
		cmdArgs = args[1:]
	}
	p := exec.Command(cmdName, cmdArgs...)
	p.Stdin = streams.OpenRead("stdin")
	p.Stdout = streams.OpenWrite("stdout")
	p.Stderr = streams.OpenWrite("stderr")
	return p.Run()
}
Beispiel #2
0
func JobHello(name string, args []string, env map[string]string, streams beam.Streamer, db beam.DB) error {
	// FIXME: can we get away with not returning errors? Maybe the server just kills the handler on error?
	stdout := streams.OpenWrite("stdout")
	fmt.Fprintf(stdout, "Hello, %s!", strings.Join(args, " "))
	return nil
}