runner

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2014 License: MIT Imports: 5 Imported by: 2

README

queued-command-runner

Build Status GoDoc

Documentation lives here

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")

  	cmd := exec.Command("ls", "-la", pwd)
  	cmd.Stdout = os.Stdout
  	cmd.Stderr = os.Stderr

  	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 Run

func Run(cmd *exec.Cmd)

Run runs your command.

Types

type QCRError

type QCRError struct {
	CommandStr string
	// contains filtered or unexported fields
}

QCRError is a custom error type that includes CommandStr, the command args of the command that failed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL