Commit 205aee66 authored by Matthew Holt's avatar Matthew Holt

Godoc comment; report -validate results to stdout too

parent 62fea30e
...@@ -492,6 +492,11 @@ func startWithListenerFds(cdyfile Input, inst *Instance, restartFds map[string]r ...@@ -492,6 +492,11 @@ func startWithListenerFds(cdyfile Input, inst *Instance, restartFds map[string]r
return nil 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 { func ValidateAndExecuteDirectives(cdyfile Input, inst *Instance, justValidate bool) error {
// If parsing only inst will be nil, create an instance for this function call only. // If parsing only inst will be nil, create an instance for this function call only.
......
...@@ -75,7 +75,7 @@ func Run() { ...@@ -75,7 +75,7 @@ func Run() {
if revoke != "" { if revoke != "" {
err := caddytls.Revoke(revoke) err := caddytls.Revoke(revoke)
if err != nil { if err != nil {
mustLogFatalf("%v", err.Error()) mustLogFatalf("%v", err)
} }
fmt.Printf("Revoked certificate for %s\n", revoke) fmt.Printf("Revoked certificate for %s\n", revoke)
os.Exit(0) os.Exit(0)
...@@ -95,7 +95,7 @@ func Run() { ...@@ -95,7 +95,7 @@ func Run() {
// Set CPU cap // Set CPU cap
err := setCPU(cpu) err := setCPU(cpu)
if err != nil { if err != nil {
mustLogFatalf("%v", err.Error()) mustLogFatalf("%v", err)
} }
// Execute plugins that are registered to run as the process starts // Execute plugins that are registered to run as the process starts
...@@ -107,23 +107,24 @@ func Run() { ...@@ -107,23 +107,24 @@ func Run() {
// Get Caddyfile input // Get Caddyfile input
caddyfileinput, err := caddy.LoadCaddyfile(serverType) caddyfileinput, err := caddy.LoadCaddyfile(serverType)
if err != nil { if err != nil {
mustLogFatalf("%v", err.Error()) mustLogFatalf("%v", err)
} }
if validate { if validate {
justValidate := true err := caddy.ValidateAndExecuteDirectives(caddyfileinput, nil, true)
err := caddy.ValidateAndExecuteDirectives(caddyfileinput, nil, justValidate)
if err != nil { 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) os.Exit(0)
} }
// Start your engines // Start your engines
instance, err := caddy.Start(caddyfileinput) instance, err := caddy.Start(caddyfileinput)
if err != nil { if err != nil {
mustLogFatalf("%v", err.Error()) mustLogFatalf("%v", err)
} }
// Twiddle your thumbs // Twiddle your thumbs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment