command

package
v0.0.0-...-f73c795 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

The command package is used to namespace commands ran though the command-line interface. The Command value is what is used to determine the top-level CLI commands. This uses a subcommand structure. This is used in conjunction with https://github.com/codegangsta/cli

Index

Constants

This section is empty.

Variables

View Source
var Commands []cli.Command = []cli.Command{
	{
		Name:  "worker",
		Usage: "Start background async batch request workers",
		Flags: []cli.Flag{
			cli.IntFlag{
				Name:  "workers, w",
				Usage: "The number of workers to start",
				Value: 1,
			},
		},
		Action: func(c *cli.Context) {
			catchSignal := make(chan os.Signal, 1)
			quit := make(chan bool, 1)
			finished := make(chan bool, 1)
			signal.Notify(catchSignal, os.Interrupt)
			go model.StartAsyncWorkers(c.Int("workers"), quit, finished)
			<-catchSignal
			log.Println("Caught interrupt signal. Waiting for workers to finish.")
			quit <- true

			select {
			case <-finished:
				log.Println("All workers finished. Shutdown successfully")
			case <-time.After(3 * time.Second):
				log.Println("All workers DID NOT finished. Forcefully shutting down")
			}
		},
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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