Add config for the periodic refresh of the videos
This commit is contained in:
parent
a14bccf75c
commit
74898cbf3f
@ -7,7 +7,9 @@ listen_port: 3000
|
|||||||
public_dir: build/public
|
public_dir: build/public
|
||||||
# default prefix, will be served by the go http server
|
# default prefix, will be served by the go http server
|
||||||
img_url_prefix: img/
|
img_url_prefix: img/
|
||||||
periodic_refresh: 12h
|
periodic_refresh:
|
||||||
|
enabled: true
|
||||||
|
interval: 12h
|
||||||
|
|
||||||
movie:
|
movie:
|
||||||
detailers:
|
detailers:
|
||||||
|
@ -13,12 +13,12 @@ import (
|
|||||||
|
|
||||||
// Config represents the Config of the canape app
|
// Config represents the Config of the canape app
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Authorizer AuthorizerConfig `yaml:"authorizer"`
|
Authorizer AuthorizerConfig `yaml:"authorizer"`
|
||||||
PGDSN string `yaml:"pgdsn"`
|
PGDSN string `yaml:"pgdsn"`
|
||||||
Port string `yaml:"listen_port"`
|
Port string `yaml:"listen_port"`
|
||||||
PublicDir string `yaml:"public_dir"`
|
PublicDir string `yaml:"public_dir"`
|
||||||
ImgURLPrefix string `yaml:"img_url_prefix"`
|
ImgURLPrefix string `yaml:"img_url_prefix"`
|
||||||
PeriodicRefresh string `yaml:"periodic_refresh"`
|
PeriodicRefresh PeriodicRefreshConfig `yaml:"periodic_refresh"`
|
||||||
|
|
||||||
MovieExplorers []polochon.Explorer
|
MovieExplorers []polochon.Explorer
|
||||||
MovieDetailers []polochon.Detailer
|
MovieDetailers []polochon.Detailer
|
||||||
@ -38,6 +38,12 @@ type AuthorizerConfig struct {
|
|||||||
Secret string `yaml:"secret"`
|
Secret string `yaml:"secret"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PeriodicRefreshConfig is the config for the periodic refresh
|
||||||
|
type PeriodicRefreshConfig struct {
|
||||||
|
Enabled bool `yaml:"enabled"`
|
||||||
|
Interval string `yaml:"interval"`
|
||||||
|
}
|
||||||
|
|
||||||
// Load loads a config file from a path and return a Config object
|
// Load loads a config file from a path and return a Config object
|
||||||
func Load(path string, log *logrus.Entry) (*Config, error) {
|
func Load(path string, log *logrus.Entry) (*Config, error) {
|
||||||
// Open the file
|
// Open the file
|
||||||
|
14
src/main.go
14
src/main.go
@ -73,12 +73,14 @@ func main() {
|
|||||||
// Create the cron object
|
// Create the cron object
|
||||||
c := cron.New()
|
c := cron.New()
|
||||||
|
|
||||||
// Refresh the library every 6h
|
if cf.PeriodicRefresh.Enabled {
|
||||||
env.Log.Debugf("Running refresh cron every %s", cf.PeriodicRefresh)
|
// Refresh the library every 6h
|
||||||
c.AddFunc(fmt.Sprintf("@every %s", cf.PeriodicRefresh), func() {
|
env.Log.Debugf("Running refresh cron every %s", cf.PeriodicRefresh.Interval)
|
||||||
env.Log.Infof("Running refresh cron!")
|
c.AddFunc(fmt.Sprintf("@every %s", cf.PeriodicRefresh.Interval), func() {
|
||||||
extmedias.Refresh(env)
|
env.Log.Infof("Running refresh cron!")
|
||||||
})
|
extmedias.Refresh(env)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Start the cron
|
// Start the cron
|
||||||
c.Start()
|
c.Start()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user