Example #1
0
// license that can be found in the LICENSE file.

// These examples demonstrate more intricate uses of the flag package.
package pflag_test

import (
	"errors"
	"fmt"
	"strings"
	"time"

	flag "github.com/pipeviz/pipeviz/Godeps/_workspace/src/github.com/spf13/pflag"
)

// Example 1: A single string flag called "species" with default value "gopher".
var species = flag.String("species", "gopher", "the species we are studying")

// Example 2: A flag with a shorthand letter.
var gopherType = flag.StringP("gopher_type", "g", "pocket", "the variety of gopher")

// Example 3: A user-defined flag type, a slice of durations.
type interval []time.Duration

// String is the method to format the flag's value, part of the flag.Value interface.
// The String method's output will be used in diagnostics.
func (i *interval) String() string {
	return fmt.Sprint(*i)
}

func (i *interval) Type() string {
	return "interval"
Example #2
0
// Pipeviz uses two separate HTTP ports - one for input into the logic
// machine, and one for graph data consumption. This is done primarily
// because security/firewall concerns are completely different, and having
// separate ports makes it much easier to implement separate policies.
// Differing semantics are a contributing, but lesser consideration.
const (
	DefaultIngestionPort int = 2309 // 2309, because Cayte
	DefaultAppPort           = 8008
	MaxMessageSize           = 5 << 20 // Max input message size is 5MB
)

var (
	bindAll    = pflag.BoolP("bind-all", "b", false, "Listen on all interfaces. Applies both to ingestor and webapp.")
	dbPath     = pflag.StringP("data-dir", "d", ".", "The base directory to use for all persistent storage.")
	useSyslog  = pflag.Bool("syslog", false, "Write log output to syslog.")
	ingestKey  = pflag.String("ingest-key", "", "Path to an x509 key to use for TLS on the ingestion port. If no cert is provided, unsecured HTTP will be used.")
	ingestCert = pflag.String("ingest-cert", "", "Path to an x509 certificate to use for TLS on the ingestion port. If key is provided, will try to find a certificate of the same name plus .crt extension.")
	webappKey  = pflag.String("webapp-key", "", "Path to an x509 key to use for TLS on the webapp port. If no cert is provided, unsecured HTTP will be used.")
	webappCert = pflag.String("webapp-cert", "", "Path to an x509 certificate to use for TLS on the webapp port. If key is provided, will try to find a certificate of the same name plus .crt extension.")
	mlstore    = pflag.StringP("mlog-storage", "", "bolt", "Storage backend to use for the message log. Valid options: 'memory' or 'bolt'. Defaults to bolt.")
)

func main() {
	pflag.Parse()
	setUpLogging()

	src, err := schema.Master()
	if err != nil {
		log.WithFields(log.Fields{
			"system": "main",
			"err":    err,
Example #3
0
// machine, and one for graph data consumption. This is done primarily
// because security/firewall concerns are completely different, and having
// separate ports makes it much easier to implement separate policies.
// Differing semantics are a contributing, but lesser consideration.
const (
	DefaultIngestionPort int = 2309 // 2309, because Cayte
	DefaultAppPort           = 8008
	MaxMessageSize           = 5 << 20 // Max input message size is 5MB
)

var (
	vflag       = pflag.BoolP("version", "v", false, "Print version")
	bindAll     = pflag.BoolP("bind-all", "b", false, "Listen on all interfaces. Applies both to ingestor and webapp.")
	dbPath      = pflag.StringP("data-dir", "d", ".", "The base directory to use for all persistent storage.")
	useSyslog   = pflag.Bool("syslog", false, "Write log output to syslog.")
	ingestKey   = pflag.String("ingest-key", "", "Path to an x509 key to use for TLS on the ingestion port. If no cert is provided, unsecured HTTP will be used.")
	ingestCert  = pflag.String("ingest-cert", "", "Path to an x509 certificate to use for TLS on the ingestion port. If key is provided, will try to find a certificate of the same name plus .crt extension.")
	webappKey   = pflag.String("webapp-key", "", "Path to an x509 key to use for TLS on the webapp port. If no cert is provided, unsecured HTTP will be used.")
	webappCert  = pflag.String("webapp-cert", "", "Path to an x509 certificate to use for TLS on the webapp port. If key is provided, will try to find a certificate of the same name plus .crt extension.")
	mlstore     = pflag.String("mlog-storage", "bolt", "Storage backend to use for the message log. Valid options: 'memory' or 'bolt'. Defaults to bolt.")
	publicDir   = pflag.String("webapp-dir", "webapp/public", "Path to the 'public' directory containing javascript application files.")
	showVersion = pflag.Bool("webapp-version", false, "Report the version of the pipeviz server via response headers")
)

func main() {
	pflag.Parse()
	if *vflag {
		fmt.Println("pipeviz version", version.Version())
		return
	}