Disable watching config file to fix #83

This commit is contained in:
WithoutPants
2019-08-23 15:27:00 +10:00
parent 32a4f34c7c
commit f0110083a8

View File

@@ -1,8 +1,9 @@
package manager package manager
import ( import (
"fmt" "net"
"github.com/fsnotify/fsnotify" "sync"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/stashapp/stash/pkg/ffmpeg" "github.com/stashapp/stash/pkg/ffmpeg"
@@ -10,8 +11,6 @@ import (
"github.com/stashapp/stash/pkg/manager/config" "github.com/stashapp/stash/pkg/manager/config"
"github.com/stashapp/stash/pkg/manager/paths" "github.com/stashapp/stash/pkg/manager/paths"
"github.com/stashapp/stash/pkg/utils" "github.com/stashapp/stash/pkg/utils"
"net"
"sync"
) )
type singleton struct { type singleton struct {
@@ -71,12 +70,15 @@ func initConfig() {
// Set generated to the metadata path for backwards compat // Set generated to the metadata path for backwards compat
viper.SetDefault(config.Generated, viper.GetString(config.Metadata)) viper.SetDefault(config.Generated, viper.GetString(config.Metadata))
// Disabling config watching due to race condition issue
// See: https://github.com/spf13/viper/issues/174
// Changes to the config outside the system will require a restart
// Watch for changes // Watch for changes
viper.WatchConfig() // viper.WatchConfig()
viper.OnConfigChange(func(e fsnotify.Event) { // viper.OnConfigChange(func(e fsnotify.Event) {
fmt.Println("Config file changed:", e.Name) // fmt.Println("Config file changed:", e.Name)
instance.refreshConfig() // instance.refreshConfig()
}) // })
//viper.Set("stash", []string{"/", "/stuff"}) //viper.Set("stash", []string{"/", "/stuff"})
//viper.WriteConfig() //viper.WriteConfig()
@@ -92,14 +94,14 @@ func initFlags() {
} }
} }
func initEnvs() { func initEnvs() {
viper.SetEnvPrefix("stash") // will be uppercased automatically viper.SetEnvPrefix("stash") // will be uppercased automatically
viper.BindEnv("host") // STASH_HOST viper.BindEnv("host") // STASH_HOST
viper.BindEnv("port") // STASH_PORT viper.BindEnv("port") // STASH_PORT
viper.BindEnv("stash") // STASH_STASH viper.BindEnv("stash") // STASH_STASH
viper.BindEnv("generated") // STASH_GENERATED viper.BindEnv("generated") // STASH_GENERATED
viper.BindEnv("metadata") // STASH_METADATA viper.BindEnv("metadata") // STASH_METADATA
viper.BindEnv("cache") // STASH_CACHE viper.BindEnv("cache") // STASH_CACHE
} }
func initFFMPEG() { func initFFMPEG() {