本文整理汇总了Golang中github.com/crunchydata/crunchy-postgresql-manager/task.TaskStatus.TaskSize方法的典型用法代码示例。如果您正苦于以下问题:Golang TaskStatus.TaskSize方法的具体用法?Golang TaskStatus.TaskSize怎么用?Golang TaskStatus.TaskSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/crunchydata/crunchy-postgresql-manager/task.TaskStatus
的用法示例。
在下文中一共展示了TaskStatus.TaskSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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")
}
示例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")
}
示例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)
}
示例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")
}
示例5: 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)
}
}
示例6: 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")
}
示例7: 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)
//.........这里部分代码省略.........