Documentation
¶
Overview ¶
Package runner runs distinct commands in parallel goroutines while queueing indistinct commands so they're never run twice at the same time (but all get run eventually).
Simply send your command to runner and let it do the rest!
Example usage:
package main
import "github.com/modcloth/queued-command-runner"
import (
"fmt"
"os"
"os/exec"
)
func main() {
fmt.Println("Running a command now.")
pwd := os.Getenv("PWD")
ls := exec.Command("ls", "-la", pwd)
ls.Stdout = os.Stdout
ls.Stderr = os.Stderr
cmd := &runner.Command{
Cmd: ls,
}
runner.Run(cmd)
WaitOnRunner:
for {
select {
case <-runner.Done:
break WaitOnRunner
case err := <-runner.Errors:
fmt.Printf("Uh oh, got an error: %q\n", err)
}
}
os.Exit(0)
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Done = make(chan bool)
Done is qcr's exit channel - if you use qcr, you MUST wait on Done to ensure your commands get run. This can be accomplished by including the following at the bottom of main():
<-runner.Done
View Source
var Errors = make(chan *QCRError)
Error is the channel that qcr will use to report any errors that occur.
Functions ¶
func SetLogLevel ¶ added in v0.2.2
SetLogLevel sets the log level (from Sirupsen/logrus) on queued-command-runner's internal logger
Types ¶
Click to show internal directories.
Click to hide internal directories.
