summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2017-01-23 23:48:12 -0700
committerMatthew Holt <[email protected]>2017-01-23 23:48:12 -0700
commit205aee6662a0090b1a3f6046725c9718f28bd8d4 (patch)
tree82e1fcc0ff06c07a1be3e5265de5b4e65c74eaa1
parent62fea30e878b571136fd9a02dd11edee69f6e2a6 (diff)
downloadcaddy-205aee6662a0090b1a3f6046725c9718f28bd8d4.tar.gz
caddy-205aee6662a0090b1a3f6046725c9718f28bd8d4.zip
Godoc comment; report -validate results to stdout too
-rw-r--r--caddy.go5
-rw-r--r--caddy/caddymain/run.go17
2 files changed, 14 insertions, 8 deletions
diff --git a/caddy.go b/caddy.go
index 7a80d1763..b55c302f3 100644
--- a/caddy.go
+++ b/caddy.go
@@ -492,6 +492,11 @@ func startWithListenerFds(cdyfile Input, inst *Instance, restartFds map[string]r
return nil
}
+// ValidateAndExecuteDirectives will load the server blocks from cdyfile
+// by parsing it, then execute the directives configured by it and store
+// the resulting server blocks into inst. If justValidate is true, parse
+// callbacks will not be executed between directives, since the purpose
+// is only to check the input for valid syntax.
func ValidateAndExecuteDirectives(cdyfile Input, inst *Instance, justValidate bool) error {
// If parsing only inst will be nil, create an instance for this function call only.
diff --git a/caddy/caddymain/run.go b/caddy/caddymain/run.go
index a38c95d37..23d938703 100644
--- a/caddy/caddymain/run.go
+++ b/caddy/caddymain/run.go
@@ -75,7 +75,7 @@ func Run() {
if revoke != "" {
err := caddytls.Revoke(revoke)
if err != nil {
- mustLogFatalf("%v", err.Error())
+ mustLogFatalf("%v", err)
}
fmt.Printf("Revoked certificate for %s\n", revoke)
os.Exit(0)
@@ -95,7 +95,7 @@ func Run() {
// Set CPU cap
err := setCPU(cpu)
if err != nil {
- mustLogFatalf("%v", err.Error())
+ mustLogFatalf("%v", err)
}
// Execute plugins that are registered to run as the process starts
@@ -107,23 +107,24 @@ func Run() {
// Get Caddyfile input
caddyfileinput, err := caddy.LoadCaddyfile(serverType)
if err != nil {
- mustLogFatalf("%v", err.Error())
+ mustLogFatalf("%v", err)
}
if validate {
- justValidate := true
- err := caddy.ValidateAndExecuteDirectives(caddyfileinput, nil, justValidate)
+ err := caddy.ValidateAndExecuteDirectives(caddyfileinput, nil, true)
if err != nil {
- mustLogFatalf("%v", err.Error())
+ mustLogFatalf("%v", err)
}
- log.Println("[INFO] Caddyfile Valid")
+ msg := "Caddyfile is valid"
+ fmt.Println(msg)
+ log.Printf("[INFO] %s", msg)
os.Exit(0)
}
// Start your engines
instance, err := caddy.Start(caddyfileinput)
if err != nil {
- mustLogFatalf("%v", err.Error())
+ mustLogFatalf("%v", err)
}
// Twiddle your thumbs