Example #1
0
File: zeus.go Project: burke/zeus
func copyFile(from, to string) (err error) {
	var src, dst *os.File
	wd, _ := os.Getwd()
	target := path.Join(wd, to)

	if src, err = os.Open(from); err != nil {
		slog.Colorized("      {red}fail{reset}  " + to)
		return err
	}
	defer src.Close()

	if dst, err = os.OpenFile(target, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666); err != nil {
		slog.Colorized("    {red}exists{reset}  " + to)
		return err
	}
	defer dst.Close()

	if _, err = io.Copy(dst, src); err != nil {
		slog.Colorized("      {red}fail{reset}  " + to)
		return err
	}

	slog.Colorized("    {brightgreen}create{reset}  " + to)
	return nil
}
Example #2
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
			}
		}
	}
}
Example #3
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
			}
		}
	}
}
Example #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
}
Example #5
0
func startingZeus() {
	slog.Colorized("{green}Starting {yellow}Z{red}e{blue}u{magenta}s{green} server")
}