From 5a0603ed72cead424a34b3bc5af3a5b1629ac187 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Tue, 31 Dec 2019 16:56:19 -0700 Subject: Config auto-save; run --resume flag; update environ output (close #2903) Config auto-saving is on by default and can be disabled. The --environ flag (or environ subcommand) now print more useful information from Caddy and the runtime, including some nifty paths. --- cmd/main.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'cmd/main.go') diff --git a/cmd/main.go b/cmd/main.go index ca9b914..564ef9f 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -110,6 +110,9 @@ func loadConfig(configFile, adapterName string) ([]byte, error) { if err != nil { return nil, fmt.Errorf("reading config file: %v", err) } + caddy.Log().Info("using provided configuration", + zap.String("config_file", configFile), + zap.String("config_adapter", adapterName)) } else if adapterName == "" { // as a special case when no config file or adapter // is specified, see if the Caddyfile adapter is @@ -126,6 +129,7 @@ func loadConfig(configFile, adapterName string) ([]byte, error) { } else { // success reading default Caddyfile configFile = "Caddyfile" + caddy.Log().Info("using adjacent Caddyfile") } } } @@ -225,6 +229,21 @@ func flagHelp(fs *flag.FlagSet) string { } func printEnvironment() { + fmt.Printf("caddy.HomeDir=%s\n", caddy.HomeDir()) + fmt.Printf("caddy.AppDataDir=%s\n", caddy.AppDataDir()) + fmt.Printf("caddy.AppConfigDir=%s\n", caddy.AppConfigDir()) + fmt.Printf("caddy.ConfigAutosavePath=%s\n", caddy.ConfigAutosavePath) + fmt.Printf("runtime.GOOS=%s\n", runtime.GOOS) + fmt.Printf("runtime.GOARCH=%s\n", runtime.GOARCH) + fmt.Printf("runtime.Compiler=%s\n", runtime.Compiler) + fmt.Printf("runtime.NumCPU=%d\n", runtime.NumCPU()) + fmt.Printf("runtime.GOMAXPROCS=%d\n", runtime.GOMAXPROCS(0)) + fmt.Printf("runtime.Version=%s\n", runtime.Version()) + cwd, err := os.Getwd() + if err != nil { + cwd = fmt.Sprintf("", err) + } + fmt.Printf("os.Getwd=%s\n\n", cwd) for _, v := range os.Environ() { fmt.Println(v) } -- cgit v1.2.3