MCPcopy Create free account
hub / github.com/Enapiuz/multiwatch / runCommands

Method runCommands

watcher/watcher.go:78–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76}
77
78func (w *Watcher) runCommands() bool {
79 result := true
80 w.errorLog = ""
81 for _, command := range w.config.Commands {
82 var outBuffer, errBuffer bytes.Buffer
83 cmd := exec.Command("sh", "-c", command)
84 cmd.Stdout = &outBuffer
85 cmd.Stderr = &errBuffer
86 err := cmd.Run()
87 if err != nil {
88 w.errorLog += fmt.Sprintf("[%s]:\n%s%s", command, outBuffer.String(), errBuffer.String())
89 result = false
90 if w.config.BreakOnFail {
91 break
92 }
93 }
94 }
95 return result
96}
97
98// GetStatus returns text representation of current watcher's status
99func (w *Watcher) GetStatus() string {

Callers 1

RunMethod · 0.95

Calls 1

RunMethod · 0.65

Tested by

no test coverage detected