Adds cron
This commit is contained in:
parent
1cc4af9c1b
commit
e056451737
1 changed files with 13 additions and 1 deletions
|
|
@ -1,7 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"github.com/robfig/cron"
|
||||
"net/http"
|
||||
"encoding/json"
|
||||
"gopkg.in/yaml.v2"
|
||||
"log"
|
||||
|
|
@ -21,6 +22,17 @@ func main() {
|
|||
}
|
||||
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()
|
||||
http.Handle("/", router)
|
||||
log.Fatal(http.ListenAndServe(":8080", router))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue