Ejemplo n.º 1
0
func StartRunnerAndMakeConnection(manifest *manifest.Manifest, log *logger.GaugeLogger, killChannel chan bool) (*TestRunner, error) {
	port, err := conn.GetPortFromEnvironmentVariable(common.GaugePortEnvName)
	if err != nil {
		port = 0
	}
	gaugeConnectionHandler, connHandlerErr := conn.NewGaugeConnectionHandler(port, nil)
	if connHandlerErr != nil {
		return nil, connHandlerErr
	}
	testRunner, err := startRunner(manifest, strconv.Itoa(gaugeConnectionHandler.ConnectionPortNumber()), log, killChannel)
	if err != nil {
		return nil, err
	}

	runnerConnection, connectionError := gaugeConnectionHandler.AcceptConnection(config.RunnerConnectionTimeout(), testRunner.ErrorChannel)
	testRunner.Connection = runnerConnection
	if connectionError != nil {
		log.Debug("Runner connection error: %s", connectionError)
		err := testRunner.killRunner()
		if err != nil {
			log.Debug("Error while killing runner: %s", err)
		}
		return nil, connectionError
	}
	return testRunner, nil
}
Ejemplo n.º 2
0
// RunInBackground runs Gauge in daemonized mode on the given apiPort
func RunInBackground(apiPort string, specDirs []string) {
	var port int
	var err error
	if apiPort != "" {
		port, err = strconv.Atoi(apiPort)
		if err != nil {
			logger.Fatalf(fmt.Sprintf("Invalid port number: %s", apiPort))
		}
		os.Setenv(common.APIPortEnvVariableName, apiPort)
	} else {
		port, err = conn.GetPortFromEnvironmentVariable(common.APIPortEnvVariableName)
		if err != nil {
			logger.Fatalf(fmt.Sprintf("Failed to start API Service. %s \n", err.Error()))
		}
	}
	runAPIServiceIndefinitely(port, specDirs)
}
Ejemplo n.º 3
0
func RunInBackground(apiPort string) {
	var port int
	var err error
	if apiPort != "" {
		port, err = strconv.Atoi(apiPort)
		os.Setenv(common.ApiPortEnvVariableName, apiPort)
		if err != nil {
			execLogger.CriticalError(errors.New(fmt.Sprintf("Failed to parse the port number :", apiPort, "\n", err.Error())))
		}
	} else {
		env.LoadEnv(false)
		port, err = conn.GetPortFromEnvironmentVariable(common.ApiPortEnvVariableName)
		if err != nil {
			execLogger.CriticalError(errors.New(fmt.Sprintf("Failed to start API Service. %s \n", err.Error())))
		}
	}
	var wg sync.WaitGroup
	runAPIServiceIndefinitely(port, &wg)
	wg.Wait()
}
Ejemplo n.º 4
0
func RunInBackground(apiPort string) {
	var port int
	var err error
	if apiPort != "" {
		port, err = strconv.Atoi(apiPort)
		if err != nil {
			logger.Fatal(fmt.Sprintf("Invalid port number: %s", apiPort))
		}
		os.Setenv(common.APIPortEnvVariableName, apiPort)
	} else {
		env.LoadEnv(false)
		port, err = conn.GetPortFromEnvironmentVariable(common.APIPortEnvVariableName)
		if err != nil {
			logger.Fatal(fmt.Sprintf("Failed to start API Service. %s \n", err.Error()))
		}
	}
	var wg sync.WaitGroup
	runAPIServiceIndefinitely(port, &wg)
	wg.Wait()
}