From ad68e97eaf08339dffd4dbc0c7180e3e612372a5 Mon Sep 17 00:00:00 2001 From: mStar Date: Thu, 7 Nov 2024 10:03:01 +0100 Subject: [PATCH] Add flag for only checking/creating the config file --- flags.go | 5 +++++ main.go | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/flags.go b/flags.go index 3875190..c8415b1 100644 --- a/flags.go +++ b/flags.go @@ -18,6 +18,11 @@ var ( "Info", "Set the logging level. Options are: Trace, Debug, Info, Warning, Error, Fatal. Capitalisation doesn't matter. Defaults to Info", ) + flagConfigOnly *bool = flag.Bool( + "validate-config", + false, + "If set, the server will only validate the config (or write the default one) and then quit", + ) ) func init() { diff --git a/main.go b/main.go index 41bac48..8b70a91 100644 --- a/main.go +++ b/main.go @@ -39,6 +39,12 @@ func main() { Str("config-file", *flagConfigFile). Msg("Failed to read config and couldn't write default") } + + // Request to only check config + if *flagConfigOnly { + return + } + storageCache, err := cache.NewCache( config.GlobalConfig.Storage.MaxInMemoryCacheSize, config.GlobalConfig.Storage.RedisUrl,