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
|
||||
# default prefix, will be served by the go http server
|
||||
img_url_prefix: img/
|
||||
periodic_refresh: 12h
|
||||
periodic_refresh:
|
||||
enabled: true
|
||||
interval: 12h
|
||||
|
||||
movie:
|
||||
detailers:
|
||||
|
@ -18,7 +18,7 @@ type Config struct {
|
||||
Port string `yaml:"listen_port"`
|
||||
PublicDir string `yaml:"public_dir"`
|
||||
ImgURLPrefix string `yaml:"img_url_prefix"`
|
||||
PeriodicRefresh string `yaml:"periodic_refresh"`
|
||||
PeriodicRefresh PeriodicRefreshConfig `yaml:"periodic_refresh"`
|
||||
|
||||
MovieExplorers []polochon.Explorer
|
||||
MovieDetailers []polochon.Detailer
|
||||
@ -38,6 +38,12 @@ type AuthorizerConfig struct {
|
||||
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
|
||||
func Load(path string, log *logrus.Entry) (*Config, error) {
|
||||
// Open the file
|
||||
|
@ -73,12 +73,14 @@ func main() {
|
||||
// Create the cron object
|
||||
c := cron.New()
|
||||
|
||||
if cf.PeriodicRefresh.Enabled {
|
||||
// Refresh the library every 6h
|
||||
env.Log.Debugf("Running refresh cron every %s", cf.PeriodicRefresh)
|
||||
c.AddFunc(fmt.Sprintf("@every %s", cf.PeriodicRefresh), func() {
|
||||
env.Log.Debugf("Running refresh cron every %s", cf.PeriodicRefresh.Interval)
|
||||
c.AddFunc(fmt.Sprintf("@every %s", cf.PeriodicRefresh.Interval), func() {
|
||||
env.Log.Infof("Running refresh cron!")
|
||||
extmedias.Refresh(env)
|
||||
})
|
||||
}
|
||||
|
||||
// Start the cron
|
||||
c.Start()
|
||||
|
Loading…
x
Reference in New Issue
Block a user