func main() { start := time.Now() flag.Parse() addr := utils.ConcateStrings(*listenAddr, ":", *listenPort) if err := loadAuthorizedClients(*configClientsFile); err != nil { log.Fatal("Impossible to load Clients Configuration File at - ", *configClientsFile) } else { log.Printf("Clients Configuration File loaded") } runningProcesses = make(map[int]Command) router := mux.NewRouter().StrictSlash(true) for _, route := range routes { var handler http.Handler handler = route.HandlerFunc handler = authorize(handler, route.Name) router. Methods(route.Method). Path(route.Pattern). Name(route.Name). Handler(handler) } log.Printf("Server Started - %s\t\t%s", addr, time.Since(start)) log.Fatal(http.ListenAndServe(addr, router)) }
func (cmd *Command) startProcess() (n int, err error) { //TODO:log start := time.Now() args := strings.Split(cmd.Arguments, " ") execcmd := exec.Command(cmd.CmdName, args...) if err := execcmd.Start(); err != nil { fmt.Println("Error running ", err) log.Printf("Error: Process not started - %s \t\t%s", args, time.Since(start)) return 0, err } cmd.PID = execcmd.Process.Pid cmd.StartingTime = time.Now() cmd.running = execcmd log.Printf("Process started - %s with PID - %d\t\t%s", utils.ConcateStrings(cmd.CmdName, cmd.Arguments), cmd.PID, time.Since(start)) return cmd.PID, nil }