88 lines
2.5 KiB
Diff
88 lines
2.5 KiB
Diff
diff -Nurp caddy-1.0.3.orig/caddy/caddymain/run.go caddy-1.0.3/caddy/caddymain/run.go
|
|
--- caddy-1.0.3.orig/caddy/caddymain/run.go 2019-08-14 14:45:42.000000000 -0500
|
|
+++ caddy-1.0.3/caddy/caddymain/run.go 2019-08-26 19:46:28.041828503 -0500
|
|
@@ -25,7 +25,6 @@ import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
- "runtime/debug"
|
|
"strconv"
|
|
"strings"
|
|
|
|
@@ -78,12 +77,10 @@ func init() {
|
|
func Run() {
|
|
flag.Parse()
|
|
|
|
- module := getBuildModule()
|
|
- cleanModVersion := strings.TrimPrefix(module.Version, "v")
|
|
-
|
|
caddy.AppName = appName
|
|
- caddy.AppVersion = module.Version
|
|
- certmagic.UserAgent = appName + "/" + cleanModVersion
|
|
+ caddy.AppVersion = appVersion
|
|
+ cleanVersion := strings.TrimPrefix(appVersion, "v")
|
|
+ certmagic.UserAgent = appName + "/" + cleanVersion
|
|
|
|
// Set up process log before anything bad happens
|
|
switch logfile {
|
|
@@ -147,12 +144,7 @@ func Run() {
|
|
os.Exit(0)
|
|
}
|
|
if version {
|
|
- if module.Sum != "" {
|
|
- // a build with a known version will also have a checksum
|
|
- fmt.Printf("Caddy %s (%s)\n", module.Version, module.Sum)
|
|
- } else {
|
|
- fmt.Println(module.Version)
|
|
- }
|
|
+ fmt.Println(appVersion)
|
|
os.Exit(0)
|
|
}
|
|
if plugins {
|
|
@@ -196,7 +188,7 @@ func Run() {
|
|
}
|
|
|
|
// Begin telemetry (these are no-ops if telemetry disabled)
|
|
- telemetry.Set("caddy_version", module.Version)
|
|
+ telemetry.Set("caddy_version", appVersion)
|
|
telemetry.Set("num_listeners", len(instance.Servers()))
|
|
telemetry.Set("server_type", serverType)
|
|
telemetry.Set("os", runtime.GOOS)
|
|
@@ -277,27 +269,6 @@ func defaultLoader(serverType string) (c
|
|
}, nil
|
|
}
|
|
|
|
-// getBuildModule returns the build info of Caddy
|
|
-// from debug.BuildInfo (requires Go modules). If
|
|
-// no version information is available, a non-nil
|
|
-// value will still be returned, but with an
|
|
-// unknown version.
|
|
-func getBuildModule() *debug.Module {
|
|
- bi, ok := debug.ReadBuildInfo()
|
|
- if ok {
|
|
- // The recommended way to build Caddy involves
|
|
- // creating a separate main module, which
|
|
- // preserves caddy a read-only dependency
|
|
- // TODO: track related Go issue: https://github.com/golang/go/issues/29228
|
|
- for _, mod := range bi.Deps {
|
|
- if mod.Path == "github.com/caddyserver/caddy" {
|
|
- return mod
|
|
- }
|
|
- }
|
|
- }
|
|
- return &debug.Module{Version: "unknown"}
|
|
-}
|
|
-
|
|
func checkJSONCaddyfile() {
|
|
if fromJSON {
|
|
jsonBytes, err := ioutil.ReadAll(os.Stdin)
|
|
@@ -578,6 +549,9 @@ func ParseEnvFile(envInput io.Reader) (m
|
|
|
|
const appName = "Caddy"
|
|
|
|
+// Build information
|
|
+var appVersion = "unknown"
|
|
+
|
|
// Flags that control program flow or startup
|
|
var (
|
|
serverType string
|