mirror of
https://github.com/foomo/neosproxy.git
synced 2026-11-30 00:31:46 +00:00
added auto-update flag
This commit is contained in:
@@ -14,7 +14,7 @@ Furthermore you need to define on which address the proxy should listen.
|
||||
The NEOS endpoint must be configured by setting the "neos" parameter as well.
|
||||
|
||||
```
|
||||
neosproxy --address=":80" --neos="https://www.myneosendpoint.com"
|
||||
neosproxy --address=":80" --neos="https://www.myneosendpoint.com" --auto-update="1h"
|
||||
```
|
||||
|
||||
web hooks
|
||||
|
||||
+22
-1
@@ -203,7 +203,6 @@ func main() {
|
||||
apiKey := os.Getenv("API_KEY")
|
||||
if apiKey == "" {
|
||||
log.Fatal("missing env variable API_KEY")
|
||||
return
|
||||
}
|
||||
|
||||
flagAddress := flag.String("address", "0.0.0.0:80", "address to listen to")
|
||||
@@ -214,6 +213,9 @@ func main() {
|
||||
flagCallbackTLSVerify := flag.Bool("callback-tls-verify", true, "skip TLS verification on web callbacks")
|
||||
flagCallbackUpdated := flag.String("callback-updated", "", "comma seperated list of urls to notify on update event")
|
||||
|
||||
// Update flags
|
||||
flagAutoUpdate := flag.String("auto-update", "", "duration value on which to automatically update the proxy")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
neosURL, err := url.Parse(*flagNeosHostname)
|
||||
@@ -232,6 +234,25 @@ func main() {
|
||||
CallbackUpdated: strings.Split(*flagCallbackUpdated, ","),
|
||||
}
|
||||
|
||||
if *flagAutoUpdate != "" {
|
||||
autoUpdate, err := time.ParseDuration(*flagAutoUpdate)
|
||||
if err != nil {
|
||||
log.Fatal("invalid auto-update duration value: " + err.Error())
|
||||
}
|
||||
go func() {
|
||||
log.Println("starting with auto update every " + *flagAutoUpdate)
|
||||
for {
|
||||
time.Sleep(autoUpdate)
|
||||
select {
|
||||
case p.CacheInvalidationChannel <- time.Now():
|
||||
log.Println("auto update: added cache invalidation request to queue")
|
||||
default:
|
||||
log.Println("auto update: ignored cache invalidation request due to pending invalidation requests")
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
fmt.Println("start proxy on ", *flagAddress, "for neos", *flagNeosHostname, "with cache file in", p.FilenameCachedContentServerExport)
|
||||
if err := p.run(); err != nil {
|
||||
log.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user