Example #1
0
func ampNode(argv []string, usage string) {

	opts := optparse.Parser(
		"Usage: amp node <config.yaml> [options]\n\n    " + usage + "\n")

	nodeHost := opts.StringConfig("node-host", "",
		"the host to bind this node to")

	nodePort := opts.IntConfig("node-port", 8050,
		"the port to bind this node to [8050]")

	ctrlHost := opts.StringConfig("control-host", "",
		"the host to bind the nodule control socket to")

	ctrlPort := opts.IntConfig("control-port", 8051,
		"the port to bind the nodule control socket to [8051]")

	nodules := opts.StringConfig("nodules", "*",
		"comma-separated list of nodules to initialise [*]")

	nodulePaths := opts.StringConfig("nodule-paths", ".",
		"comma-separated list of nodule container directories [nodule]")

	masterNodes := opts.StringConfig("master-nodes", "localhost:8060",
		"comma-separated addresses of amp master nodes [localhost:8060]")

	masterKeyPath := opts.StringConfig("master-key", "cert/master.key",
		"the path to the file containing the amp master public key [cert/master.key]")

	debug, _, runPath := runtime.DefaultOpts("node", opts, argv, nil)

	masterClient, err := master.NewClient(*masterNodes, *masterKeyPath)

	if err != nil {
		runtime.StandardError(err)
	}

	logging.AddConsoleFilter(nodule.FilterConsoleLog)

	node, err := nodule.NewHost(
		runPath, *nodeHost, *nodePort, *ctrlHost, *ctrlPort, *nodules,
		strings.SplitN(*nodulePaths, ",", -1), masterClient)

	if err != nil {
		runtime.StandardError(err)
	}

	err = node.Run(debug)
	logging.Wait()

	if err != nil {
		runtime.Exit(1)
	}

}
Example #2
0
func ampReview(argv []string, usage string) {

	args := handleCommon("review", usage, argv)
	status := 0

	for _, nodule := range getNodules(args) {
		err := nodule.Review()
		if err != nil {
			status = 1
			break
		}
	}

	logging.Wait()
	runtime.Exit(status)

}