Example #1
0
func ErrorConfigCommandCouldntStart(output string) {
	slog.Red("Failed to initialize application from {yellow}zeus.json{red}.")
	if slog.Red("The json file is valid, but the {yellow}command{red} could not be started:") {
		fmt.Println(output)
		ExitNow(1)
	}
}
Example #2
0
func ErrorConfigCommandCrashed(output string) {
	slog.Red("Failed to initialize application from {yellow}zeus.json{red}.")
	if slog.Red("The json file is valid, but the {yellow}command{red} terminated with this output:") {
		fmt.Println(output)
		ExitNow(1)
	}
}
Example #3
0
func ErrorConfigCommandCrashed(output string) {
	if !suppressErrors {
		slog.Red("Failed to initialize application from " + yellow + "zeus.json" + red + ".")
		slog.Red("The json file is valid, but the " + yellow + "command" + red + " terminated with this output:")
		fmt.Println(output)
		ExitNow(1)
	}
}
Example #4
0
func ErrorConfigCommandCouldntStart(output string) {
	if !suppressErrors {
		slog.Red("Failed to initialize application from " + yellow + "zeus.json" + red + ".")
		slog.Red("The json file is valid, but the " + yellow + "command" + red + " could not be started:")
		fmt.Println(output)
		ExitNow(1)
	}
}
Example #5
0
func startWrapper(filesChanged chan string) *exec.Cmd {
	path := executablePath()
	cmd := exec.Command(path[0], path[1:]...)
	var err error
	if watcherIn, err = cmd.StdinPipe(); err != nil {
		terminate(err.Error())
	}
	if watcherOut, err = cmd.StdoutPipe(); err != nil {
		terminate(err.Error())
	}
	if watcherErr, err = cmd.StderrPipe(); err != nil {
		terminate(err.Error())
	}

	cmd.Start()

	go func() {
		buf := make([]byte, 2048)
		for {
			n, err := watcherOut.Read(buf)
			if err != nil {
				time.Sleep(500 * time.Millisecond)
				slog.Red("Failed to read from FileSystem watcher process: " + err.Error())
			}
			message := strings.TrimSpace(string(buf[:n]))
			files := strings.Split(message, "\n")
			for _, file := range files {
				filesChanged <- file
			}
		}
	}()

	go func() {
		err := cmd.Wait()
		// gross, but this is an easy way to work around the case where
		// signal propagation hits the wrapper before the master disables logging
		time.Sleep(100 * time.Millisecond)
		terminate("The FS watcher process crashed: " + err.Error())
	}()

	return cmd
}
Example #6
0
func Error(msg string) {
	if slog.Red(msg) {
		ExitNow(1)
	}
}
Example #7
0
func errorFailedReadFromWatcher(err error) {
	if !suppressErrors {
		slog.Red("Failed to read from FileSystem watcher process: " + err.Error())
	}
}
Example #8
0
func ErrorFileMonitorWrapperCrashed(err error) {
	if !suppressErrors {
		slog.Red("The FileSystem watcher process crashed: " + err.Error())
		ExitNow(1)
	}
}
Example #9
0
func ErrorCantCreateListener() {
	if !suppressErrors {
		slog.Red("It looks like Zeus is already running. If not, remove " + yellow + ".zeus.sock" + red + " and try again.")
		ExitNow(1)
	}
}
Example #10
0
func errorUnableToAcceptSocketConnection() {
	if !suppressErrors {
		slog.Red("Unable to accept socket connection.")
	}
}
Example #11
0
func ErrorConfigFileInvalidJson() {
	if !suppressErrors {
		slog.Red("The config file " + yellow + "zeus.json" + red + " contains invalid JSON and could not be parsed.")
		os.Exit(1)
	}
}
Example #12
0
func ErrorConfigFileInvalidFormat() {
	if !suppressErrors {
		slog.Red("The config file " + yellow + "zeus.json" + red + " is not in the correct format.")
		os.Exit(1)
	}
}
Example #13
0
File: zerror.go Project: nevir/zeus
func ErrorConfigCommandCrashed(output string) {
	ExitNow(1, func() {
		slog.Red("Couldn't boot application. {yellow}command{red} terminated with this output:")
		fmt.Println(output)
	})
}
Example #14
0
// The config file is loaded before any goroutines arything is done that requires cleanup,
// and our exitNow goroutine has not been spawned yet, so we will just explicitly exit
// in the json-related errors..
func ErrorConfigFileMissing() {
	if !suppressErrors {
		slog.Red("Required config file " + yellow + "zeus.json" + red + " not found in the current directory.")
		os.Exit(1)
	}
}
Example #15
0
func ErrorCantConnectToMaster() {
	slog.Red("Can't connect to master. Run {yellow}zeus start{red} first.\r")
	os.Exit(1)
}
Example #16
0
File: zerror.go Project: nevir/zeus
func ErrorConfigCommandCouldntStart(msg, output string) {
	ExitNow(1, func() {
		slog.Red("Failed to initialize application from {yellow}zeus.json{red}.")
		slog.Red("The json file is valid, but the {yellow}command{red} could not be started:\n\x1b[0m" + output)
	})
}
Example #17
0
func errorUnableToAcceptSocketConnection() {
	slog.Red("Unable to accept socket connection.")
}
Example #18
0
func ErrorCantCreateListener() {
	if slog.Red("It looks like Zeus is already running. If not, remove {yellow}.zeus.sock{red} and try again.") {
		ExitNow(1)
	}
}
Example #19
0
func ErrorConfigFileInvalidFormat() {
	if slog.Red("The config file {yellow}zeus.json{red} is not in the correct format.") {
		os.Exit(1)
	}
}
Example #20
0
func ErrorConfigFileInvalidJson() {
	if slog.Red("The config file {yellow}zeus.json{red} contains invalid JSON and could not be parsed.") {
		os.Exit(1)
	}
}
Example #21
0
// The config file is loaded before any goroutines are launched that require cleanup,
// and our exitNow goroutine has not been spawned yet, so we will just explicitly exit
// in the json-related errors..
func ErrorConfigFileMissing() {
	if slog.Red("Required config file {yellow}zeus.json{red} not found in the current directory.") {
		os.Exit(1)
	}
}
Example #22
0
func terminate(message string) {
	slog.Red(message)
	println(message)
	proc, _ := os.FindProcess(os.Getpid())
	proc.Signal(syscall.SIGTERM)
}
Example #23
0
File: zerror.go Project: nevir/zeus
func Error(msg string) {
	ExitNow(1, func() {
		slog.Red(msg)
	})
}