mirror of
https://github.com/Luzifer/go-latestver.git
synced 2024-12-20 10:31:16 +00:00
Allow to disable filesystem watcher
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
7838e8e037
commit
d3261d7434
1 changed files with 7 additions and 4 deletions
11
main.go
11
main.go
|
@ -28,6 +28,7 @@ var (
|
|||
Storage string `flag:"storage" default:"sqlite" description:"Storage adapter to use (mysql, sqlite)"`
|
||||
StorageDSN string `flag:"storage-dsn" default:"file::memory:?cache=shared" description:"DSN to connect to the database"`
|
||||
VersionAndExit bool `flag:"version" default:"false" description:"Prints current version and exits"`
|
||||
WatchConfig bool `flag:"watch-config" default:"true" description:"Whether to watch the config file for changes"`
|
||||
}{}
|
||||
|
||||
configFile = config.New()
|
||||
|
@ -68,11 +69,13 @@ func main() {
|
|||
log.WithError(err).Fatal("Configuration is not valid")
|
||||
}
|
||||
|
||||
fsWatch, err := fileHelper.NewSimpleWatcher(cfg.Config, time.Minute)
|
||||
if err != nil {
|
||||
log.WithError(err).Fatal("creating config file watcher")
|
||||
if cfg.WatchConfig {
|
||||
fsWatch, err := fileHelper.NewSimpleWatcher(cfg.Config, time.Minute)
|
||||
if err != nil {
|
||||
log.WithError(err).Fatal("creating config file watcher")
|
||||
}
|
||||
go reloadConfigOnChange(fsWatch)
|
||||
}
|
||||
go reloadConfigOnChange(fsWatch)
|
||||
|
||||
storage, err = database.NewClient(cfg.Storage, cfg.StorageDSN)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue