diff --git a/README.md b/README.md index 09759373..14d235f3 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ Have any feedback or questions? [Create a discussion](https://github.com/TwiN/ga - [Endpoint groups](#endpoint-groups) - [Exposing Gatus on a custom path](#exposing-gatus-on-a-custom-path) - [Exposing Gatus on a custom port](#exposing-gatus-on-a-custom-port) + - [Configuring a startup delay](#configuring-a-startup-delay) - [Keeping your configuration small](#keeping-your-configuration-small) - [Badges](#badges) - [Uptime](#uptime) @@ -1864,6 +1865,10 @@ web: ``` +### Configuring a startup delay +If, for any reason, you need Gatus to wait for a given amount of time before monitoring the endpoints on application start, you can use the `GATUS_DELAY_START_SECONDS` environment variable to make Gatus sleep on startup. + + ### Keeping your configuration small While not specific to Gatus, you can leverage YAML anchors to create a default configuration. If you have a large configuration file, this should help you keep things clean. diff --git a/main.go b/main.go index cd0c5972..462ea874 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "log" "os" "os/signal" + "strconv" "syscall" "time" @@ -14,6 +15,10 @@ import ( ) func main() { + if delayInSeconds, _ := strconv.Atoi(os.Getenv("GATUS_DELAY_START_SECONDS")); delayInSeconds > 0 { + log.Printf("Delaying start by %d seconds", delayInSeconds) + time.Sleep(time.Duration(delayInSeconds) * time.Second) + } cfg, err := loadConfiguration() if err != nil { panic(err)