func runSupervisor() (status int) { monolog.Setup("woe.log", true, false) defer monolog.Close() enableDisableLogs() monolog.Info("Starting WOE supervisor.") for server_restart { // wd , _ := os.Getwd() exe := fmt.Sprintf("%s", os.Args[0]) argp := fmt.Sprintf("-l=%s", *server_tcpip) argel := fmt.Sprintf("-el=%s", *enable_logs) argdl := fmt.Sprintf("-dl=%s", *disable_logs) cmd := exec.Command(exe, "-s=true", argp, argel, argdl) monolog.Info("Starting server %s at %s.", exe, *server_tcpip) cmd.Stderr = os.Stderr cmd.Stdout = os.Stdout monolog.Debug("Server command line: %s.", cmd.Args) err := cmd.Run() monolog.Info("Server at %s shut down.", *server_tcpip) if err != nil { monolog.Error("Server shut down with error %s!", err) server_restart = false return 1 } } return 0 }
func runServer() (status int) { monolog.Setup("woe.log", true, false) defer monolog.Close() enableDisableLogs() monolog.Info("Starting WOE server...") monolog.Info("Server will run at %s.", *server_tcpip) woe, err := server.NewServer(*server_tcpip) if err != nil { monolog.Error("Could not initialize server!") monolog.Error(err.Error()) panic(err) } monolog.Info("Server at %s init ok.", *server_tcpip) defer woe.Close() status, err = woe.Serve() if err != nil { monolog.Error("Error while running WOE server!") monolog.Error(err.Error()) panic(err) } monolog.Info("Server shut down without error indication.", *server_tcpip) return status }