• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang task.TaskStatus类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/crunchydata/crunchy-postgresql-manager/task.TaskStatus的典型用法代码示例。如果您正苦于以下问题:Golang TaskStatus类的具体用法?Golang TaskStatus怎么用?Golang TaskStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TaskStatus类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: main

func main() {

	fmt.Println("backupcommand running....")
	_, err := io.WriteString(file, "backupcommand running....\n")
	if err != nil {
		fmt.Println(err.Error())
	}

	defer closeLog()

	getEnvVars()
	s := task.TaskStatus{}
	eDuration := time.Since(startTime)
	s.StartTime = startTimeString
	//s.ElapsedTime = eDuration.String()
	s.ElapsedTime = fmt.Sprintf("%.3fs", eDuration.Seconds())
	s.Status = "initializing"
	s.TaskSize = du()
	sendStats(&s)

	//kick off stats reporting in a separate thread
	go stats("hi")

	fmt.Println("giving DNS time to register the backup job...sleeping for 7s")
	io.WriteString(file, "giving DNS time to register the backup job....sleeping for 7 secs")
	sleepTime, _ := time.ParseDuration("7s")
	time.Sleep(sleepTime)

	//perform the backup
	backupfunc("end")

	//send final stats to backup
	finalstats("end")

}
开发者ID:rogervaas,项目名称:crunchy-postgresql-manager,代码行数:35,代码来源:backupcommand.go


示例2: finalstats

//report stats back to the cpm-admin for this backup job
func finalstats(str string) {

	//connect to backupserver on cpm-admin
	//send stats to backup
	stats := task.TaskStatus{}
	eDuration := time.Since(startTime)
	stats.StartTime = startTimeString
	stats.ElapsedTime = eDuration.String()
	stats.Status = "completed"
	stats.TaskSize = "n/a"

	sendStats(&stats)
	logit.Info.Println("final stats here")
}
开发者ID:rogervaas,项目名称:crunchy-postgresql-manager,代码行数:15,代码来源:backrestrestorecommand.go


示例3: stats

//report stats back to the cpm-admin for this job
func stats(str string) {

	sleepTime, _ := time.ParseDuration("7s")

	//logit.Info.Println("sending stats...")
	//logit.Info.Println("sleeping for 7 secs")
	time.Sleep(sleepTime)
	stats := task.TaskStatus{}
	eDuration := time.Since(startTime)
	stats.StartTime = startTimeString
	stats.ElapsedTime = eDuration.String()
	stats.Status = str
	stats.TaskSize = "n/a"
	sendStats(&stats)
}
开发者ID:rogervaas,项目名称:crunchy-postgresql-manager,代码行数:16,代码来源:backrestrestorecommand.go


示例4: finalstats

//report stats back to the cpm-admin for this backup job
func finalstats(str string) {

	//connect to backupserver on cpm-admin
	//send stats to backup
	stats := task.TaskStatus{}
	eDuration := time.Since(startTime)
	stats.StartTime = startTimeString
	//stats.ElapsedTime = eDuration.String()
	stats.ElapsedTime = fmt.Sprintf("%.3fs", eDuration.Seconds())
	stats.Status = "completed"
	stats.TaskSize = du()

	sendStats(&stats)
	fmt.Println("final stats here")
	io.WriteString(file, "final stats here\n")
}
开发者ID:rogervaas,项目名称:crunchy-postgresql-manager,代码行数:17,代码来源:backupcommand.go


示例5: sendStats

func sendStats(stats *task.TaskStatus) error {
	logit.Info.Println("restore - " + restoreBackupPath + " to " + restoreContainerName + " - " + stats.Status)

	stats.Status = "restore - " + restoreBackupPath + " to " + restoreContainerName + " - " + stats.Status
	stats.ContainerName = restoreContainerName
	stats.ScheduleID = restoreScheduleID
	stats.ProfileName = "restore"
	stats.Path = restoreContainerName
	stats.TaskName = restoreContainerName
	stats.ID = StatusID

	var addResponse task.StatusAddResponse
	var err error

	if StatusID != "" {
		_, err = task.StatusUpdateClient(stats)
	} else {
		addResponse, err = task.StatusAddClient(stats)
		StatusID = addResponse.ID
	}
	if err != nil {
		logit.Error.Println("error in adding status:" + err.Error())
		return err
	}

	return nil
}
开发者ID:rogervaas,项目名称:crunchy-postgresql-manager,代码行数:27,代码来源:restorecommand.go


示例6: stats

//report stats back to the cpm-admin for this backup job
func stats(str string) {

	sleepTime, _ := time.ParseDuration("7s")

	for true {
		fmt.Println("sending stats...")
		io.WriteString(file, "sending stats...\n")
		io.WriteString(file, "sleeping for 7 secs\n")
		time.Sleep(sleepTime)
		stats := task.TaskStatus{}
		eDuration := time.Since(startTime)
		stats.StartTime = startTimeString
		//stats.ElapsedTime = eDuration.String()
		stats.ElapsedTime = fmt.Sprintf("%.3fs", eDuration.Seconds())
		stats.Status = "running"
		stats.TaskSize = du()
		sendStats(&stats)
	}
}
开发者ID:rogervaas,项目名称:crunchy-postgresql-manager,代码行数:20,代码来源:backupcommand.go


示例7: sendStats

func sendStats(stats *task.TaskStatus) error {
	stats.ContainerName = backupContainerName
	stats.ScheduleID = scheduleID
	stats.ProfileName = backupProfileName
	stats.Path = backupPath
	stats.TaskName = backupHost
	stats.ID = StatusID
	fmt.Println("jeff: containername=" + stats.ContainerName)
	fmt.Println("jeff: scheduleid=" + stats.ScheduleID)
	fmt.Println("jeff: ProfileName=" + stats.ProfileName)
	fmt.Println("jeff: Path=" + stats.Path)
	fmt.Println("jeff: TaskName=" + stats.TaskName)
	fmt.Println("jeff: ID=" + stats.ID)

	var addResponse task.StatusAddResponse
	var err error

	if StatusID != "" {
		_, err = task.StatusUpdateClient(stats)
	} else {
		addResponse, err = task.StatusAddClient(stats)
		StatusID = addResponse.ID
	}
	if err != nil {
		fmt.Println(err.Error())
		io.WriteString(file, "error in adding status:"+err.Error()+"\n")
		return err
	}

	//send to backup
	fmt.Println("elapsed time:" + stats.ElapsedTime)
	io.WriteString(file, "elapsed time:"+stats.ElapsedTime+"\n")
	fmt.Println("tasksize :" + stats.TaskSize)
	io.WriteString(file, "tasksize :"+stats.TaskSize+"\n")
	return nil
}
开发者ID:rogervaas,项目名称:crunchy-postgresql-manager,代码行数:36,代码来源:backupcommand.go


示例8: main

func main() {

	startTime = time.Now()
	startTimeString = startTime.String()
	logit.Info.Println("backrestrestore running....")

	err := getEnvVars()
	if err != nil {
		logit.Error.Println(err.Error())
		return
	}

	s := task.TaskStatus{}
	eDuration := time.Since(startTime)
	s.StartTime = startTimeString
	s.ElapsedTime = eDuration.String()
	s.Status = "initializing"
	s.TaskSize = "n/a"
	sendStats(&s)

	logit.Info.Println("giving DNS time to register the backup job....sleeping for 7 secs")
	sleepTime, _ := time.ParseDuration("7s")
	time.Sleep(sleepTime)

	stats("restore job starting")

	stats("stopping postgres...")
	var stopResponse cpmcontainerapi.StopPGResponse
	stopResponse, err = cpmcontainerapi.StopPGClient(restoreContainerName)
	if err != nil {
		logit.Error.Println(err.Error())
		s.Status = "error in stopPG"
		sendStats(&s)
		os.Exit(1)
	}
	logit.Info.Println("StopPG....")
	logit.Info.Println(stopResponse.Output)
	logit.Info.Println(stopResponse.Status)
	logit.Info.Println("End of StopPG....")

	//wait for postgres to quit
	time.Sleep(sleepTime)

	stats("performing the restore...")
	//perform the restore
	restoreRequest := cpmcontainerapi.RestoreRequest{}
	restoreRequest.RestoreRemotePath = restoreRemotePath
	restoreRequest.RestoreRemoteHost = restoreRemoteHost
	restoreRequest.RestoreRemoteUser = restoreRemoteUser
	restoreRequest.RestoreDbUser = restoreDbUser
	restoreRequest.RestoreDbPass = restoreDbPass
	restoreRequest.RestoreSet = restoreSet

	var restoreResponse cpmcontainerapi.RestoreResponse
	restoreResponse, err = cpmcontainerapi.RestoreClient(restoreContainerName, &restoreRequest)
	if err != nil {
		logit.Error.Println(err.Error())
		s.Status = "error in restore"
		sendStats(&s)
		os.Exit(1)
	}
	logit.Info.Println("Restore....")
	logit.Info.Println(restoreResponse.Output)
	logit.Info.Println(restoreResponse.Status)
	logit.Info.Println("End of Restore....")

	stats("starting postgres after the restore...")

	var startResponse cpmcontainerapi.StartPGResponse
	startResponse, err = cpmcontainerapi.StartPGClient(restoreContainerName)
	if err != nil {
		logit.Error.Println(err.Error())
		s.Status = "error in startPG"
		sendStats(&s)
		os.Exit(1)
	}
	logit.Info.Println("StartPG....")
	logit.Info.Println(startResponse.Output)
	logit.Info.Println(startResponse.Status)
	logit.Info.Println("End of StartPG....")

	stats("seeding the database...")
	var seedResponse cpmcontainerapi.SeedResponse
	seedResponse, err = cpmcontainerapi.SeedClient(restoreContainerName)
	if err != nil {
		logit.Error.Println(err.Error())
		s.Status = "error in Seed"
		sendStats(&s)
		os.Exit(1)
	}
	logit.Info.Println("Seed....")
	logit.Info.Println(seedResponse.Output)
	logit.Info.Println(seedResponse.Status)
	logit.Info.Println("End of Seed....")

	//send final stats to backup
	finalstats("restore completed")

}
开发者ID:rogervaas,项目名称:crunchy-postgresql-manager,代码行数:99,代码来源:backrestrestorecommand.go


示例9: main

func main() {

	startTime = time.Now()
	startTimeString = startTime.String()
	logit.Info.Println("backrestrestore running....")

	err := getEnvVars()
	if err != nil {
		logit.Error.Println(err.Error())
		return
	}

	s := task.TaskStatus{}
	eDuration := time.Since(startTime)
	s.StartTime = startTimeString
	//s.ElapsedTime = eDuration.String()
	s.ElapsedTime = fmt.Sprintf("%.3fs", eDuration.Seconds())
	s.Status = "initializing"
	s.TaskSize = "n/a"
	sendStats(&s)

	//	logit.Info.Println("giving DNS time to register the backup job....sleeping for 7 secs")
	sleepTime, _ := time.ParseDuration("7s")
	//	time.Sleep(sleepTime)

	stats("restore job starting")

	stats("stopping postgres...")
	var stopResponse cpmcontainerapi.StopPGResponse
	stopResponse, err = cpmcontainerapi.StopPGClient(restoreContainerName)
	if err != nil {
		logit.Error.Println(err.Error())
		s.Status = "error in stopPG"
		sendStats(&s)
		os.Exit(1)
	}
	logit.Info.Println("StopPG....")
	logit.Info.Println(stopResponse.Output)
	logit.Info.Println(stopResponse.Status)
	logit.Info.Println("End of StopPG....")

	//wait for postgres to quit
	time.Sleep(sleepTime)

	stats("performing the restore...")
	//perform the restore
	//remove anything left in the /pgdata on the receiving container
	logit.Info.Println("removing any existing pgdata files")
	var frompath string
	frompath = "/pgdata/" + restorePath + "/*"
	logit.Info.Println("/bin/rm -rf " + frompath)
	var cmd *exec.Cmd
	cmd = exec.Command("/bin/rm", "-rf", frompath)
	var out bytes.Buffer
	var stderr bytes.Buffer
	cmd.Stdout = &out
	cmd.Stderr = &stderr
	err = cmd.Run()
	if err != nil {
		logit.Error.Println(err.Error())
		logit.Error.Println("rm stdout=" + out.String())
		logit.Error.Println("rm stderr=" + stderr.String())
		s.Status = "error in removing old files"
		sendStats(&s)
		os.Exit(1)
	}
	logit.Info.Println("remove was successful")

	//I'm choosing to do the remove here this way since this restore
	//might be a HUGE amount of data and the copy command could run a LONG
	//time, longer than an http timeout might allow for, since restorecommand
	//is running inside a container itself, this copy can run any amount of time

	//copy from the backup path all files to the /pgdata on the receiving container
	frompath = " /pgdata" + restoreBackupPath
	topath := "  /pgdata/" + restorePath
	logit.Info.Println("/var/cpm/bin/copyfiles.sh" + frompath + topath)
	cmd = exec.Command("/var/cpm/bin/copyfiles.sh", frompath, topath)
	cmd.Stdout = &out
	cmd.Stderr = &stderr
	err = cmd.Run()
	if err != nil {
		logit.Error.Println(err.Error())
		s.Status = "error in copying backup files"
		logit.Error.Println("cp stdout=" + out.String())
		logit.Error.Println("cp stderr=" + stderr.String())
		sendStats(&s)
		os.Exit(1)
	}

	logit.Info.Println("restore - copy of files was successful...")

	stats("starting postgres after the restore...")

	var startResponse cpmcontainerapi.StartPGResponse
	startResponse, err = cpmcontainerapi.StartPGClient(restoreContainerName)
	if err != nil {
		logit.Error.Println(err.Error())
		s.Status = "error in startPG"
		sendStats(&s)
//.........这里部分代码省略.........
开发者ID:rogervaas,项目名称:crunchy-postgresql-manager,代码行数:101,代码来源:restorecommand.go



注:本文中的github.com/crunchydata/crunchy-postgresql-manager/task.TaskStatus类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang types.Container类代码示例发布时间:2022-05-23
下一篇:
Golang util.GetConnection函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap