Skip to content

Commit

Permalink
run command in separate goroutine to prevent block
Browse files Browse the repository at this point in the history
  • Loading branch information
radovskyb committed Aug 10, 2017
1 parent 6a2d149 commit 6145e14
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cmd/watcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,17 @@ func main() {
}()

// Run the command before watcher starts if one was specified.
if *cmd != "" && *startcmd {
c := exec.Command(cmdName, cmdArgs...)
c.Stdin = os.Stdin
c.Stdout = os.Stdout
c.Stderr = os.Stderr
if err := c.Run(); err != nil {
log.Fatalln(err)
go func() {
if *cmd != "" && *startcmd {
c := exec.Command(cmdName, cmdArgs...)
c.Stdin = os.Stdin
c.Stdout = os.Stdout
c.Stderr = os.Stderr
if err := c.Run(); err != nil {
log.Fatalln(err)
}
}
}
}()

// Start the watching process.
if err := w.Start(parsedInterval); err != nil {
Expand Down

0 comments on commit 6145e14

Please sign in to comment.