mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 00:04:15 -04:00
coredns: default Corefile (#265)
When no Corefile is given, default to loading the whoami middleware on the default port (2053). Also add back the -port flag that allows you to override the default port. Further cleanup the startup messages and use caddy's OnStartupComplete() to blurp out which zones and ports we have. These can be suppressed with the -quiet flag. Normal startup: miek.nl.:1053 miek.nl2.:1053 example.org.:1054 2016/09/17 20:41:19 [INFO] CoreDNS-001 starting CoreDNS-001 starting with the -quiet flag: 2016/09/17 20:41:34 [INFO] CoreDNS-001 starting
This commit is contained in:
@@ -13,8 +13,9 @@ import (
|
||||
|
||||
"github.com/mholt/caddy"
|
||||
|
||||
"github.com/miekg/coredns/core/dnsserver"
|
||||
// Plug in CoreDNS
|
||||
"github.com/miekg/coredns/core"
|
||||
_ "github.com/miekg/coredns/core"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -28,7 +29,6 @@ func init() {
|
||||
flag.BoolVar(&plugins, "plugins", false, "List installed plugins")
|
||||
flag.StringVar(&logfile, "log", "", "Process log file")
|
||||
flag.StringVar(&caddy.PidFile, "pidfile", "", "Path to write pid file")
|
||||
flag.BoolVar(&core.Quiet, "quiet", false, "Quiet mode (no initialization output)")
|
||||
flag.BoolVar(&version, "version", false, "Show version")
|
||||
|
||||
caddy.RegisterCaddyfileLoader("flag", caddy.LoaderFunc(confLoader))
|
||||
@@ -80,34 +80,12 @@ func Run() {
|
||||
}
|
||||
|
||||
logVersion()
|
||||
showVersion()
|
||||
|
||||
// Twiddle your thumbs
|
||||
instance.Wait()
|
||||
}
|
||||
|
||||
// startNotification will log CoreDNS' version to the log.
|
||||
func startupNotification() {
|
||||
if core.Quiet {
|
||||
return
|
||||
}
|
||||
logVersion()
|
||||
}
|
||||
|
||||
func showVersion() {
|
||||
fmt.Printf("%s-%s\n", caddy.AppName, caddy.AppVersion)
|
||||
if devBuild && gitShortStat != "" {
|
||||
fmt.Printf("%s\n%s\n", gitShortStat, gitFilesModified)
|
||||
}
|
||||
}
|
||||
|
||||
// logVersion logs the version that is starting.
|
||||
func logVersion() {
|
||||
log.Printf("[INFO] %s-%s starting\n", caddy.AppName, caddy.AppVersion)
|
||||
if devBuild && gitShortStat != "" {
|
||||
log.Printf("[INFO] %s\n%s\n", gitShortStat, gitFilesModified)
|
||||
}
|
||||
}
|
||||
|
||||
// mustLogFatal wraps log.Fatal() in a way that ensures the
|
||||
// output is always printed to stderr so the user can see it
|
||||
// if the user is still there, even if the process log was not
|
||||
@@ -158,6 +136,25 @@ func defaultLoader(serverType string) (caddy.Input, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// logVersion logs the version that is starting.
|
||||
func logVersion() { log.Print("[INFO] " + versionString()) }
|
||||
|
||||
// showVersion prints the version that is starting.
|
||||
func showVersion() {
|
||||
if dnsserver.Quiet {
|
||||
return
|
||||
}
|
||||
fmt.Print(versionString())
|
||||
if devBuild && gitShortStat != "" {
|
||||
fmt.Printf("%s\n%s\n", gitShortStat, gitFilesModified)
|
||||
}
|
||||
}
|
||||
|
||||
// versionString returns the CoreDNS version as a string.
|
||||
func versionString() string {
|
||||
return fmt.Sprintf("%s-%s starting\n", caddy.AppName, caddy.AppVersion)
|
||||
}
|
||||
|
||||
// setVersion figures out the version information
|
||||
// based on variables set by -ldflags.
|
||||
func setVersion() {
|
||||
|
||||
Reference in New Issue
Block a user