Example #1
0
func TestDefaultExec(t *testing.T) {
	// tests whether the default config has the correct command or not
	exec_cmd := "node app.js"
	defaultConfig := GetDefaultConfig(exec_cmd)
	supervisorConfig, _ := arguments.GetModuleConfig(defaultConfig, "supervisor")
	configEntry, _ := supervisorConfig.GetConfigValue("exec")

	if configEntry.Value == exec_cmd {
		t.Log("success")
	} else {
		t.Error("default exec command does not match arguments")
	}
}
Example #2
0
func TestDefaultParamsCount(t *testing.T) {
	// test whether the default config has correct number of parameters
	exec_cmd := "node app.js"
	defaultConfig := GetDefaultConfig(exec_cmd)
	supervisorConfig, _ := arguments.GetModuleConfig(defaultConfig, "supervisor")

	configParamsCount := len(supervisorConfig.Values)
	validParamsCount := len(VALID_PARAMS)
	if configParamsCount == validParamsCount {
		fmt.Printf("%v\n", supervisorConfig)
		t.Log("success")
	} else {
		fmt.Printf("%v\n", supervisorConfig)
		//TODO: multiliine go statement
		t.Error(fmt.Sprintf("Invalid config entries count, \nValid: %d, Received %d\n", validParamsCount, configParamsCount))
	}
}
Example #3
0
func Boot(config []arguments.ModuleConfig) (started bool, err error) {
	log.Printf("%v", config)
	supervisorConfig, err := arguments.GetModuleConfig(config, "supervisor")
	if isValidConfig, err := validateConfig(supervisorConfig.Values); isValidConfig == false {
		log.Printf("Invalid configuation in config file")
		return false, err
	}
	configEntry, _ := supervisorConfig.GetConfigValue("exec")
	proc := NewProc(fmt.Sprintf("%s", configEntry.Value))
	safeExit, procErr := proc.Start()
	if procErr == nil && safeExit == true {
		log.Printf(fmt.Sprintf("%v", proc))
		return true, nil
	} else {
		log.Printf(fmt.Sprintf("Error while starting command"))
		return safeExit, procErr
	}
}