Esempio n. 1
0
func doRun() int {
	slog.Colorized("{green}Starting {yellow}Z{red}e{blue}u{magenta}s{green} server")

	zerror.Init()
	var tree *processtree.ProcessTree = config.BuildProcessTree()

	done := make(chan bool)

	// Start processes and register them for exit when the function returns.
	filesChanged, filemonitorDone := filemonitor.Start(done)

	defer exit(processtree.StartSlaveMonitor(tree, done), done)
	defer exit(clienthandler.Start(tree, done), done)
	defer exit(filemonitorDone, done)
	defer slog.Suppress()
	defer zerror.PrintFinalOutput()
	defer exit(statuschart.Start(tree, done), done)

	c := make(chan os.Signal, 1)
	signal.Notify(c, terminatingSignals...)

	for {
		select {
		case sig := <-c:
			if sig == syscall.SIGINT {
				return 0
			} else {
				return 1
			}
		case changed := <-filesChanged:
			go tree.RestartNodesWithFeature(changed)
		}
	}
	return -1 // satisfy the compiler
}
Esempio n. 2
0
func zoomsCommands() {
	tree := config.BuildProcessTree()
	for _, command := range tree.Commands {
		alia := strings.Join(command.Aliases, ", ")
		var aliasPart string
		if len(alia) > 0 {
			aliasPart = " (alias: " + alia + ")"
		}
		println("zooms " + command.Name + aliasPart)
	}
}
Esempio n. 3
0
func main() {
	if len(os.Args) == 1 {
		execManPage("zooms")
	}

	var args []string
	if os.Args[1] == "--no-color" {
		color = false
		slog.DisableColor()
		args = os.Args[2:]
	} else {
		args = os.Args[1:]
	}

	if generalHelpRequested(args) {
		execManPage("zooms")
	} else if args[0] == "help" {
		commandSpecificHelp(args)
	} else if args[0] == "version" || args[0] == "--version" {
		println("Zooms version " + zoomsversion.VERSION)
	} else if args[0] == "start" {
		zoomsmaster.Run()
	} else if args[0] == "init" {
		zoomsInit()
	} else if args[0] == "commands" {
		zoomsCommands()
	} else {
		tree := config.BuildProcessTree()
		for _, name := range tree.AllCommandsAndAliases() {
			if args[0] == name {
				zoomsclient.Run()
				return
			}
		}

		commandNotFound(args[0])
	}
}