jpillora / overseer

Monitorable, gracefully restarting, self-upgrading binaries in Go (golang)
MIT License
2.32k stars 209 forks source link

Fetcher HTTP: Add support for dynamic URL #28

Open moisespsena opened 5 years ago

moisespsena commented 5 years ago

Add support for dynamic URL with URLFunc Attribute:

func main() {
    overseer.Run(overseer.Config{
        Program: prog,
        Fetcher: &fetcher.HTTP{
            URLFunc: func() (URL string, err ERROR) {
                t := time.Now()
                nows := fmt.Printf(
                    "%d-%02d-%02d_%02d%02d%02d",
                    t.Year(), t.Month(), t.Day(),
                    t.Hour(), t.Minute(), t.Second(),
                )
                return "http://localhost:4000/binaries/myapp-" + nows, nil
            },
        },
    })
}