示例#1
0
文件: main.go 项目: nanopack/logvac
func startLogvac(ccmd *cobra.Command, args []string) error {
	// initialize logger
	lumber.Level(lumber.LvlInt(config.LogLevel)) // for clients using lumber too
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt(config.LogLevel))

	// initialize logvac
	logvac.Init()

	// setup authenticator
	err := authenticator.Init()
	if err != nil {
		return fmt.Errorf("Authenticator failed to initialize - %v", err)
	}

	// initialize drains
	err = drain.Init()
	if err != nil {
		return fmt.Errorf("Drain failed to initialize - %v", err)
	}

	// initializes collectors
	err = collector.Init()
	if err != nil {
		return fmt.Errorf("Collector failed to initialize - %v", err)
	}

	err = api.Start(collector.CollectHandler)
	if err != nil {
		return fmt.Errorf("Api failed to initialize - %v", err)
	}

	return nil
}
示例#2
0
// manually configure and start internals
func initialize() {
	config.ListenHttp = "127.0.0.1:4234"
	config.ListenTcp = "127.0.0.1:4235"
	config.ListenUdp = "127.0.0.1:4234"
	config.DbAddress = "boltdb:///tmp/syslogTest/logvac.bolt"
	config.AuthAddress = ""
	config.Insecure = true
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt("ERROR"))

	// initialize logvac
	logvac.Init()

	// setup authenticator
	err := authenticator.Init()
	if err != nil {
		config.Log.Fatal("Authenticator failed to initialize - %v", err)
		os.Exit(1)
	}

	// initialize drains
	err = drain.Init()
	if err != nil {
		config.Log.Fatal("Drain failed to initialize - %v", err)
		os.Exit(1)
	}

	// initializes collectors
	err = collector.Init()
	if err != nil {
		config.Log.Fatal("Collector failed to initialize - %v", err)
		os.Exit(1)
	}
}
示例#3
0
// manually configure and start internals
func initialize() error {
	http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
	config.ListenHttp = "127.0.0.1:3234"
	config.ListenTcp = "127.0.0.1:3235"
	config.ListenUdp = "127.0.0.1:3234"
	config.DbAddress = "boltdb:///tmp/authTest/logvac.bolt"
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt("ERROR"))

	// initialize logvac
	logvac.Init()

	// setup authenticator
	config.AuthAddress = ""
	err := authenticator.Init()
	if err != nil {
		return fmt.Errorf("Authenticator failed to initialize - %v", err)
	}
	config.AuthAddress = "file:///tmp/authTest/logvac-auth.bolt"
	err = authenticator.Init()
	if err != nil {
		return fmt.Errorf("Authenticator failed to initialize - %v", err)
	}
	config.AuthAddress = "~!@#$%^&*()_"
	err = authenticator.Init()
	if err == nil {
		return fmt.Errorf("Authenticator failed to initialize - %v", err)
	}
	config.AuthAddress = "boltdb:///tmp/authTest/logvac-auth.bolt"
	err = authenticator.Init()
	if err != nil {
		return fmt.Errorf("Authenticator failed to initialize - %v", err)
	}

	// initialize drains
	err = drain.Init()
	if err != nil {
		return fmt.Errorf("Drain failed to initialize - %v", err)
	}

	// initializes collectors
	err = collector.Init()
	if err != nil {
		return fmt.Errorf("Collector failed to initialize - %v", err)
	}

	return nil
}
示例#4
0
文件: main.go 项目: nanopack/logvac
func addKey(ccmd *cobra.Command, args []string) error {
	err := authenticator.Init()
	if err != nil {
		return fmt.Errorf("Authenticator failed to initialize - %v", err)
	}

	err = authenticator.Add(tokenName)
	if err != nil {
		return fmt.Errorf("Failed to add token '%v' - %v", tokenName, err)
	}

	return nil
}
示例#5
0
文件: main.go 项目: nanopack/logvac
func importLogvac(ccmd *cobra.Command, args []string) error {
	err := authenticator.Init()
	if err != nil {
		return fmt.Errorf("Authenticator failed to initialize - %v", err)
	}

	var importReader io.Reader
	if portFile != "" {
		importReader, err = os.Open(portFile)
		if err != nil {
			return fmt.Errorf("Failed to open file - %v", err)
		}
	} else {
		importReader = os.NewFile(uintptr(syscall.Stdin), "/dev/stdin") // stdin
	}

	err = authenticator.ImportLogvac(importReader)
	if err != nil {
		return fmt.Errorf("Failed to import - %v", err)
	}

	return nil
}
示例#6
0
文件: main.go 项目: nanopack/logvac
func exportLogvac(ccmd *cobra.Command, args []string) error {
	err := authenticator.Init()
	if err != nil {
		return fmt.Errorf("Authenticator failed to initialize - %v", err)
	}

	var exportWriter io.Writer
	if portFile != "" {
		exportWriter, err = os.Create(portFile)
		if err != nil {
			return fmt.Errorf("Failed to open file - %v", err)
		}
	} else {
		exportWriter = os.NewFile(uintptr(syscall.Stdout), "/dev/stdout") // stdout
	}

	err = authenticator.ExportLogvac(exportWriter)
	if err != nil {
		return fmt.Errorf("Failed to export - %v", err)
	}

	return nil
}
示例#7
0
// manually configure and start internals
func initialize() {
	http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
	secureHttp = "127.0.0.1:2236"
	insecureHttp = "127.0.0.1:2234"
	config.Insecure = true
	config.ListenHttp = "127.0.0.1:2234"
	config.ListenTcp = "127.0.0.1:2235"
	config.ListenUdp = "127.0.0.1:2234"
	config.DbAddress = "boltdb:///tmp/apiTest/logvac.bolt"
	config.AuthAddress = ""
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt("ERROR"))

	// initialize logvac
	logvac.Init()

	// setup authenticator
	err := authenticator.Init()
	if err != nil {
		config.Log.Fatal("Authenticator failed to initialize - %v", err)
		os.Exit(1)
	}

	// initialize drains
	err = drain.Init()
	if err != nil {
		config.Log.Fatal("Drain failed to initialize - %v", err)
		os.Exit(1)
	}

	// initializes collectors
	err = collector.Init()
	if err != nil {
		config.Log.Fatal("Collector failed to initialize - %v", err)
		os.Exit(1)
	}
}