From 5fd35254a8f60cd311d8239cbc3f94122b252275 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Tue, 30 Apr 2019 15:26:57 +0300 Subject: [PATCH] + app: add --check-config command-line argument --- app.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app.go b/app.go index 2ad14472..7ba0fedf 100644 --- a/app.go +++ b/app.go @@ -104,6 +104,11 @@ func run(args options) { if err != nil { os.Exit(1) } + + if args.checkConfig { + log.Info("Configuration file is OK") + os.Exit(0) + } } if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") && @@ -401,6 +406,7 @@ type options struct { bindPort int // port to serve HTTP pages on logFile string // Path to the log file. If empty, write to stdout. If "syslog", writes to syslog pidFile string // File name to save PID to + checkConfig bool // Check configuration and exit // service control action (see service.ControlAction array + "status" command) serviceControlAction string @@ -438,6 +444,7 @@ func loadOptions() options { o.logFile = value }, nil}, {"pidfile", "", "File name to save PID to", func(value string) { o.pidFile = value }, nil}, + {"check-config", "", "Check configuration and exit", nil, func() { o.checkConfig = true }}, {"verbose", "v", "enable verbose output", nil, func() { o.verbose = true }}, {"help", "", "print this help", nil, func() { printHelp()