Example #1
0
func (ad *AtDebug) ReopenLogFile() error {

	if ad.logFile != nil {
		ad.logFile.Close()
	}

	t := time.Now()
	ad.FileName = fmt.Sprintf("log-%d-%02d-%02dT%02d:%02d:%02d",
		t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second())

	log_path := ad.RootPath + ad.LogPath
	log_filename := ad.RootPath + ad.LogPath + ad.FileName
	fmt.Printf("\nlog_file_name = [%s]\n", log_filename)

	var err error

	if is_been, _ := at.CheckPathExists(log_path); !is_been {
		if err = os.MkdirAll(log_path, 0777); err != nil {
			return err
		}
	}

	ad.logFile, err = os.OpenFile(log_filename, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
	if err != nil {
		return err
	}

	return nil
}
Example #2
0
func (jtl *JtlFrame) LoadScript(filename string) error {

	jtl.FileName = filename
	ad.Println("script filename  = [%s]", jtl.FileName)

	if is_been, _ := at.CheckPathExists(jtl.FileName); !is_been {

		ad.Println("fail do not exist script file = [%s]", jtl.FileName)
		return errors.New("fail read script file")

	}

	if b, err := ioutil.ReadFile(jtl.FileName); err != nil {

		ad.Println("fail read script file = [%s]", jtl.FileName)
		return errors.New("fail read script file")

	} else {

		if err := json.Unmarshal(b, &(jtl.Script)); err != nil {
			ad.Println("fail convert script file = [%s]", jtl.FileName)
			ad.Println("err : [%s]", err)
			return errors.New("fail read script file")
		}
	}

	return nil
}
Example #3
0
func (ar *AtReport) ReopenReportFile() error {

	if ar.rptFile != nil {
		ar.rptFile.Close()
	}

	t := time.Now()
	ar.FileName = fmt.Sprintf("rpt-%d-%02d-%02dT%02d:%02d:%02d",
		t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second())

	rpt_path := ar.RootPath + ar.ReportPath
	rpt_filename := ar.RootPath + ar.ReportPath + ar.FileName
	fmt.Printf("\nrpt_file_name = [%s]\n", rpt_filename)

	var err error

	if is_been, _ := at.CheckPathExists(rpt_path); !is_been {
		if err = os.MkdirAll(rpt_path, 0777); err != nil {
			return err
		}
	}

	ar.rptFile, err = os.OpenFile(rpt_filename, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
	if err != nil {
		return err
	}

	return nil
}
Example #4
0
//  새로운 JEU 를 만든다
func (jtl *JtlFrame) RunScriptCmdRun(cmd JtlFrameCommandJson) bool {

	data_json, err := json.Marshal(cmd.Data)
	if err != nil {
		reason := fmt.Sprintf("script file syntax error")
		ar.SetResultError(reason)
		return false
	}

	data_str := string(data_json)
	ad.Println("script run command id = [%s] path = [%s] data = [%s]", cmd.Id, cmd.Path, data_str)

	// JEU 실행 프로그램 파일이 있는가를 확인한다.
	if is_been, _ := at.CheckPathExists(cmd.Path); !is_been {

		ad.Println("fail do not find exec file [%s]", cmd.Path)
		reason := fmt.Sprintf("do not find exec file [%s]", cmd.Path)
		ar.SetResultError(reason)
		return false

	}

	// 컴포넌트의 실행 프로그램을 수행한다.
	if err := sh.Command(cmd.Path, cmd.Id, data_str).Start(); err != nil {
		ad.Println("fail do not exec file [%s]", cmd.Path)
		reason := fmt.Sprintf("do not exec file [%s]", cmd.Path)
		ar.SetResultError(reason)
		return false
	}

	// 컴포넌트가 등록되었음을 알리는 메세지를 기다린다.
	ad.Println("wait register JEU [%s]", cmd.Id)
	var loop_out int
	var been bool

	for loop_out = 10; loop_out > 0; loop_out-- {
		been, err = js.CheckJEU(cmd.Id)

		if err != nil {
			ad.Println("fail check been of JEU [%s]", cmd.Id)
			reason := fmt.Sprintf("do not check been of JEU [%s]", cmd.Id)
			ar.SetResultError(reason)
			return false
		}

		if been {
			break
		}
		time.Sleep(10 * time.Millisecond)
	}
	if loop_out == 0 {
		ad.Println("fail register JEU [%s]", cmd.Id)
		reason := fmt.Sprintf("do not register JEU [%s]", cmd.Id)
		ar.SetResultError(reason)
		return false
	}

	return true
}