Adds cron
This commit is contained in:
parent
1cc4af9c1b
commit
e056451737
1 changed files with 13 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/robfig/cron"
|
||||||
"net/http"
|
"net/http"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
@ -21,6 +22,17 @@ func main() {
|
||||||
}
|
}
|
||||||
config.SharedSecret = os.Getenv("SHARED_SECRET")
|
config.SharedSecret = os.Getenv("SHARED_SECRET")
|
||||||
|
|
||||||
|
c := cron.New()
|
||||||
|
err = c.AddFunc("@hourly", func() {
|
||||||
|
loadSpaceData()
|
||||||
|
getCalendars()
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Can't start cron %v", err)
|
||||||
|
} else {
|
||||||
|
c.Start()
|
||||||
|
}
|
||||||
|
|
||||||
router := NewRouter()
|
router := NewRouter()
|
||||||
http.Handle("/", router)
|
http.Handle("/", router)
|
||||||
log.Fatal(http.ListenAndServe(":8080", router))
|
log.Fatal(http.ListenAndServe(":8080", router))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue