Merge branch 'periodicRefresh' into 'master'

Add a config to set the info refresh interval

See merge request !83
This commit is contained in:
Grégoire Delattre 2017-06-12 11:42:09 +00:00
commit a14bccf75c
3 changed files with 10 additions and 6 deletions

View File

@ -7,6 +7,7 @@ listen_port: 3000
public_dir: build/public
# default prefix, will be served by the go http server
img_url_prefix: img/
periodic_refresh: 12h
movie:
detailers:

View File

@ -13,11 +13,12 @@ import (
// Config represents the Config of the canape app
type Config struct {
Authorizer AuthorizerConfig `yaml:"authorizer"`
PGDSN string `yaml:"pgdsn"`
Port string `yaml:"listen_port"`
PublicDir string `yaml:"public_dir"`
ImgURLPrefix string `yaml:"img_url_prefix"`
Authorizer AuthorizerConfig `yaml:"authorizer"`
PGDSN string `yaml:"pgdsn"`
Port string `yaml:"listen_port"`
PublicDir string `yaml:"public_dir"`
ImgURLPrefix string `yaml:"img_url_prefix"`
PeriodicRefresh string `yaml:"periodic_refresh"`
MovieExplorers []polochon.Explorer
MovieDetailers []polochon.Detailer

View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"net/http"
"os"
@ -73,7 +74,8 @@ func main() {
c := cron.New()
// Refresh the library every 6h
c.AddFunc("@every 6h", func() {
env.Log.Debugf("Running refresh cron every %s", cf.PeriodicRefresh)
c.AddFunc(fmt.Sprintf("@every %s", cf.PeriodicRefresh), func() {
env.Log.Infof("Running refresh cron!")
extmedias.Refresh(env)
})