func main() { flag.Parse() // called here in main() to allow other packages to set flags in their inits caddy.AppName = appName caddy.AppVersion = appVersion acme.UserAgent = appName + "/" + appVersion // set up process log before anything bad happens switch logfile { case "stdout": log.SetOutput(os.Stdout) case "stderr": log.SetOutput(os.Stderr) case "": log.SetOutput(ioutil.Discard) default: log.SetOutput(&lumberjack.Logger{ Filename: logfile, MaxSize: 100, MaxAge: 14, MaxBackups: 10, }) } if revoke != "" { err := https.Revoke(revoke) if err != nil { log.Fatal(err) } fmt.Printf("Revoked certificate for %s\n", revoke) os.Exit(0) } if version { fmt.Printf("%s %s\n", caddy.AppName, caddy.AppVersion) os.Exit(0) } // Set CPU cap err := setCPU(cpu) if err != nil { mustLogFatal(err) } // Get Caddyfile input caddyfile, err := caddy.LoadCaddyfile(loadCaddyfile) if err != nil { mustLogFatal(err) } // Start your engines err = caddy.Start(caddyfile) if err != nil { mustLogFatal(err) } // Twiddle your thumbs caddy.Wait() }
func main() { flag.Parse() // called here in main() to allow other packages to set flags in their inits caddy.AppName = appName caddy.AppVersion = appVersion acme.UserAgent = appName + "/" + appVersion // set up process log before anything bad happens switch logfile { case "stdout": log.SetOutput(os.Stdout) case "stderr": log.SetOutput(os.Stderr) case "": log.SetOutput(ioutil.Discard) default: file, err := os.OpenFile(logfile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) if err != nil { log.Fatalf("Error opening process log file: %v", err) } log.SetOutput(file) } if revoke != "" { err := https.Revoke(revoke) if err != nil { log.Fatal(err) } fmt.Printf("Revoked certificate for %s\n", revoke) os.Exit(0) } if version { fmt.Printf("%s %s\n", caddy.AppName, caddy.AppVersion) os.Exit(0) } // Set CPU cap err := setCPU(cpu) if err != nil { mustLogFatal(err) } // Get Caddyfile input caddyfile, err := caddy.LoadCaddyfile(loadCaddyfile) if err != nil { mustLogFatal(err) } // Start your engines err = caddy.Start(caddyfile) if err != nil { mustLogFatal(err) } // Twiddle your thumbs caddy.Wait() }