Ejemplo n.º 1
0
func main() {
	if len(os.Args) != 3 {
		println("Usage:", os.Args[0], "AnchorPath Service")
		os.Exit(1)
	}
	file, err := anchorfs.OpenFile(os.Args[1])
	if err != nil {
		fmt.Fprintf(os.Stderr, "Problem opening (%s)", err)
		os.Exit(1)
	}
	x, err := circuit.TryDial(file.Owner(), "acid")
	if err != nil {
		fmt.Fprintf(os.Stderr, "Problem dialing 'acid' service (%s)", err)
		os.Exit(1)
	}

	defer func() {
		if p := recover(); p != nil {
			fmt.Fprintf(os.Stderr, "Worker disappeared during call (%#v)", p)
			os.Exit(1)
		}
	}()

	r := x.Call("OnBehalfCallStringer", os.Args[2], "Stat")
	fmt.Println(r[0].(string))
}
Ejemplo n.º 2
0
func main() {
	if len(os.Args) != 2 {
		println("Usage:", os.Args[0], "AnchorPath")
		os.Exit(1)
	}
	file, err := anchorfs.OpenFile(os.Args[1])
	if err != nil {
		log.Printf("Problem opening (%s)", err)
		os.Exit(1)
	}
	x, err := circuit.TryDial(file.Owner(), "acid")
	if err != nil {
		log.Printf("Problem dialing acid service (%s)", err)
		os.Exit(1)
	}

	defer func() {
		if p := recover(); p != nil {
			log.Printf("Worker disappeared during call (%#v)", p)
			os.Exit(1)
		}
	}()

	retrn := x.Call("RuntimeProfile", "goroutine", 1)
	if err, ok := retrn[1].(error); ok && err != nil {
		log.Printf("Problem obtaining runtime profile (%s)", err)
		os.Exit(1)
	}
	fmt.Println(string(retrn[0].([]byte)))
}
Ejemplo n.º 3
0
func main() {
	if len(os.Args) != 3 {
		println("Usage:", os.Args[0], "AnchorPath PathWithinJail")
		os.Exit(1)
	}
	f, err := anchorfs.OpenFile(os.Args[1])
	if err != nil {
		fmt.Fprintf(os.Stderr, "Problem opening (%s)", err)
		os.Exit(1)
	}

	tailViaSSH(f.Owner(), os.Args[2])
}
Ejemplo n.º 4
0
func main() {
	if len(os.Args) != 3 {
		println("Usage:", os.Args[0], "AnchorPath DurationSeconds")
		os.Exit(1)
	}

	// Parse duration
	dursec, err := strconv.Atoi(os.Args[2])
	if err != nil {
		fmt.Fprintf(os.Stderr, "Problem parsing duration (%s)\n", err)
		os.Exit(1)
	}
	dur := time.Duration(int64(dursec) * 1e9)

	// Find anchor file
	file, err := anchorfs.OpenFile(os.Args[1])
	if err != nil {
		fmt.Fprintf(os.Stderr, "Problem opening (%s)\n", err)
		os.Exit(1)
	}
	x, err := circuit.TryDial(file.Owner(), "acid")
	if err != nil {
		fmt.Fprintf(os.Stderr, "Problem dialing acid service (%s)\n", err)
		os.Exit(1)
	}

	defer func() {
		if p := recover(); p != nil {
			fmt.Fprintf(os.Stderr, "Worker disappeared during call (%#v)\n", p)
			os.Exit(1)
		}
	}()

	// Connect to worker
	retrn := x.Call("CPUProfile", dur)
	if err, ok := retrn[1].(error); ok && err != nil {
		fmt.Fprintf(os.Stderr, "Problem obtaining CPU profile (%s)\n", err)
		os.Exit(1)
	}
	fmt.Println(string(retrn[0].([]byte)))
}
Ejemplo n.º 5
0
func main() {
	flag.Usage = usage
	flag.Parse()

	anchor, file, recurse, err := parse(flag.Arg(0))
	if err != nil {
		usage()
	}
	if file {
		f, err := anchorfs.OpenFile(anchor)
		if err != nil {
			log.Printf("Problem opening (%s)", err)
			os.Exit(1)
		}
		if err = worker.Kill(f.Owner()); err != nil {
			log.Printf("Problem killing (%s)", err)
			os.Exit(1)
		}
		os.Exit(0)
	}
	if err = killdir(anchor, recurse); err != nil {
		os.Exit(1)
	}
}