Esempio n. 1
0
// Called at the start of a test to setup all the various state bits that
// are needed. All tests in this module should start by calling this
// function.
func StartTest(l Logger) {
	if !streamTestOutput {
		LogBuffer = unittest.SetupBuffer()
	} else {
		logray.AddDefaultOutput("stdout://", logray.ALL)
	}
}
Esempio n. 2
0
func main() {
	logray.AddDefaultOutput("stdout://", logray.ALL)

	opts := &api.Options{}

	s := api.New(opts)
	if err := s.Start(); err != nil {
		panic(err)
	}
}
Esempio n. 3
0
// Sets up everything needed to unit test against a LogBuffer object.
// The returned object will use numerical counters rather than dates in
// order to make the output predictable.
func SetupBuffer() *LogBuffer {
	b := new(LogBuffer)
	newOutput := func(u *url.URL) (logray.Output, error) {
		return b, nil
	}
	logray.ResetCachedOutputs()
	logray.ResetDefaultOutput()
	logray.AddNewOutputFunc("logbuffer", newOutput)
	logray.AddDefaultOutput("logbuffer://", logray.ALL)
	return b
}
Esempio n. 4
0
func main() {
	u := url.URL{
		Scheme: "stdout",
		RawQuery: url.Values(map[string][]string{
			"format": []string{formatString},
		}).Encode(),
	}
	logray.AddDefaultOutput(u.String(), logray.INFOPLUS)

	if err := kinit.Run(); err != nil {
		fmt.Fprintf(os.Stderr, "Failure running process: %v", err)
	}
	runtime.Goexit()
}
Esempio n. 5
0
func main() {
	var configFile string
	var logLevel string

	flag.StringVar(&configFile, "f", "", "file to use to define processes")
	flag.StringVar(&logLevel, "log-levle", "info+", "log message levels to be logged")
	flag.Parse()

	// validate we have a config file
	if configFile == "" {
		fmt.Fprint(os.Stderr, "No config file specified with -f\n")
		os.Exit(1)
	}

	// validate the configured log level
	logclass, err := logray.ParseLogClass(logLevel)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to parse log class: %v\n", err)
		os.Exit(1)
	}
	logray.AddDefaultOutput("stdout://", logclass)
	log = logray.New()

	// load the config file
	config, err := loadConfig(configFile)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to load config file: %v\n", err)
		os.Exit(1)
	}

	// begin the signal handling
	handleSigterm()

	// begin managing processes
	wg := sync.WaitGroup{}
	for _, args := range config {
		wg.Add(1)
		go func(args []string) {
			defer wg.Done()
			manageProcess(args)
		}(args)
	}

	// wait for all to finish
	wg.Wait()
}
Esempio n. 6
0
func main() {
	logray.AddDefaultOutput("stdout://", logray.ALL)

	directory, err := os.Getwd()
	if err != nil {
		panic(err)
	}

	opts := &server.Options{
		ParentCgroupName:   "kurma",
		ContainerDirectory: directory,
		RequiredNamespaces: []string{"ipc", "mount", "pid", "uts"},
	}

	s := server.New(opts)
	if err := s.Start(); err != nil {
		panic(err)
	}
}