Skip to content

Commit

Permalink
addressed review comment
Browse files Browse the repository at this point in the history
Signed-off-by: REGGEENR <[email protected]>
  • Loading branch information
reggeenr committed Jul 25, 2022
1 parent 6febbe6 commit 7cc5a89
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions helloworld/helloworld.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,25 +209,27 @@ func main() {
// Start a endless for loop
for {
sleep := os.Getenv("SLEEP")
sleepDuration := 0
if sleep != "" {
len, _ := strconv.Atoi(sleep)
if len > 0 {
Debug(false, "Sleeping %d", len)
time.Sleep(time.Duration(len) * time.Second)
}
sleepDuration, _ = strconv.Atoi(sleep)
} else if jobMode == "daemon" {
// Sleep for 60 seconds and then re-do the execution
sleepDuration = 60
}

// Check whether the job should sleep a while before printing the helloworld statement
if sleepDuration > 0 {
Debug(false, "Sleeping %ds", sleepDuration)
time.Sleep(time.Duration(sleepDuration) * time.Second)
}

fmt.Printf("Hello from helloworld! I'm a %s job! Index: %s\n\n",
jobMode, jobIndex)
fmt.Printf("Hello from helloworld! I'm a %s job! Index: %s\n\n", jobMode, jobIndex)
PrintMessage(os.Stdout, os.Getenv("SHOW") == "")

if jobMode == "task" {
// If this job is of type task, let exit the loop
// If this job is of type task (aka run-to-completion), let it exit the loop
break
}

// Sleep for another 60 seconds and then re-do the execution
time.Sleep(time.Duration(60) * time.Second)
}

} else {
Expand Down

0 comments on commit 7cc5a89

Please sign in to comment.