Ejemplo n.º 1
0
func doRun() int {
	slog.Colorized("{green}Starting {yellow}Z{red}e{blue}u{magenta}s{green} server v" + zeusversion.VERSION)

	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 exit(restarter.Start(tree, filesChanged, done), 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
			}
		}
	}
}
Ejemplo n.º 2
0
func Run(configFile string, fileChangeDelay time.Duration) int {
	slog.Colorized("{green}Starting {yellow}Z{red}e{blue}u{magenta}s{green} server v" + zeusversion.VERSION)

	zerror.Init()

	monitor, err := buildFileMonitor(fileChangeDelay)
	if err != nil {
		return 2
	}

	var tree = config.BuildProcessTree(configFile, monitor)

	done := make(chan bool)

	defer exit(processtree.StartSlaveMonitor(tree, monitor.Listen(), done), done)
	defer exit(clienthandler.Start(tree, done), done)
	defer monitor.Close()
	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
			}
		}
	}
}
Ejemplo n.º 3
0
func terminateComponents(quit1, quit2, quit3, quit chan bool) {
	slog.Suppress()
	go func() {
		quit1 <- true
		<-quit1
		quit <- true
	}()
	go func() {
		quit2 <- true
		<-quit2
		quit <- true
	}()
	go func() {
		quit3 <- true
		<-quit3
		quit <- true
	}()
}
Ejemplo n.º 4
0
func doRun() int {
	slog.Colorized("{green}Starting {yellow}Z{red}e{blue}u{magenta}s{green} server")

	var tree *ProcessTree = BuildProcessTree()

	done := make(chan bool)
	// Start processes and register them for exit when the function returns.
	defer exit(StartSlaveMonitor(tree, done), done)
	defer exit(StartClientHandler(tree, done), done)
	defer exit(StartFileMonitor(tree, done), done)
	defer exit(StartStatusChart(tree, done), done)
	defer slog.Suppress()

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

	select {
	case <-c:
		return 0
	case exitStatus := <-exitNow:
		return exitStatus
	}
	return -1 // satisfy the compiler
}