Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't sigterm on failed run - Reduce frequency. #13

Merged
merged 1 commit into from
Oct 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func checkRunState(runLockFileLocation string) error {
// Check for puppet running state by inspecting the lockfile & remove if > 25 mins old.
if filestat, err := os.Stat(runLockFileLocation); err == nil {
now := time.Now()
cutoff := 25 * time.Minute
cutoff := 180 * time.Minute
if diff := now.Sub(filestat.ModTime()); diff > cutoff {
if err := os.Remove(runLockFileLocation); err != nil {
log.Fatalf("Unable to remove lockfile %s.\n", runLockFileLocation)
Expand Down Expand Up @@ -64,7 +64,7 @@ func runPuppet(runConfig puppetRunConfig) {
// Sleep until we need to run
delay := 0
if !*runConfig.now {
delay = random(15, 45)
delay = random(60, 180)
}
log.Printf("Delaying puppet-nanny run by %d minutes", delay)
time.Sleep(time.Duration(delay) * time.Minute)
Expand All @@ -84,9 +84,11 @@ func runPuppet(runConfig puppetRunConfig) {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
log.Fatalf("%v failed with %s.\n", cmd, err)
log.Printf("%v failed with %s.\n", cmd, err)
}
if cmd.ProcessState.ExitCode() == 0 {
log.Print("Puppet run succeeded.\n")
}
log.Print("Puppet run succeeded.\n")
}

func main() {
Expand Down