mirror of
https://github.com/TwiN/gatus.git
synced 2024-11-21 23:43:27 +01:00
feat: add ability to delay startup (#631)
* Feat: add ability to delay startup * Enable ability to set delay seconds before start up gatus * Update README.md * Delete .examples/delay-startup/Makefile --------- Co-authored-by: TwiN <twin@linux.com>
This commit is contained in:
parent
3c246f0c69
commit
1e82d2f07d
@ -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.
|
||||
|
5
main.go
5
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)
|
||||
|
Loading…
Reference in New Issue
Block a user