expiration-mailer daemon mode (#2631)

Adds a daemon mode to `expiration-mailer` that is triggered by using the flag `--daemon` in order to follow deployability guidelines. If the `--daemon` flag is used the `mailer.runPeriod` config field is checked for a tick duration, if the value is `0` it exits.

Super lightweight implementation, OCSP-Updater has some custom ticker code which we use to do fancy things when the method being invoked in the loop takes longer expected, but that isn't necessary here.

Fixes #2617.
This commit is contained in:
Roland Bracewell Shoemaker 2017-03-30 16:16:41 -07:00 committed by Jacob Hoffman-Andrews
parent cefb153ea7
commit 98addd5f36
2 changed files with 19 additions and 3 deletions

View File

@ -377,6 +377,8 @@ type config struct {
// Path to a text/template email template
EmailTemplate string
Frequency cmd.ConfigDuration
TLS cmd.TLSConfig
SAService *cmd.GRPCClientConfig
@ -393,6 +395,7 @@ func main() {
certLimit := flag.Int("cert_limit", 0, "Count of certificates to process per expiration period")
reconnBase := flag.Duration("reconnectBase", 1*time.Second, "Base sleep duration between reconnect attempts")
reconnMax := flag.Duration("reconnectMax", 5*60*time.Second, "Max sleep duration between reconnect attempts after exponential backoff")
daemon := flag.Bool("daemon", false, "Run in daemon mode")
flag.Parse()
@ -510,6 +513,18 @@ func main() {
go cmd.DebugServer(c.Mailer.DebugAddr)
err = m.findExpiringCertificates()
cmd.FailOnError(err, "expiration-mailer has failed")
if *daemon {
if c.Mailer.Frequency.Duration == 0 {
fmt.Fprintln(os.Stderr, "mailer.runPeriod is not set")
os.Exit(1)
}
t := time.NewTicker(c.Mailer.Frequency.Duration)
for range t.C {
err = m.findExpiringCertificates()
cmd.FailOnError(err, "expiration-mailer has failed")
}
} else {
err = m.findExpiringCertificates()
cmd.FailOnError(err, "expiration-mailer has failed")
}
}

View File

@ -20,7 +20,8 @@
"saService": {
"serverAddresses": ["sa.boulder:9095"],
"timeout": "15s"
}
},
"frequency": "1h"
},
"statsd": {