Set version to unknown if not set (#4521)
This commit is contained in:
parent
98a785b077
commit
31e1c04ed0
|
@ -58,22 +58,11 @@ var fService = flag.String("service", "",
|
||||||
var fRunAsConsole = flag.Bool("console", false, "run as console application (windows only)")
|
var fRunAsConsole = flag.Bool("console", false, "run as console application (windows only)")
|
||||||
|
|
||||||
var (
|
var (
|
||||||
nextVersion = "1.8.0"
|
version string
|
||||||
version string
|
commit string
|
||||||
commit string
|
branch string
|
||||||
branch string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
// If commit or branch are not set, make that clear.
|
|
||||||
if commit == "" {
|
|
||||||
commit = "unknown"
|
|
||||||
}
|
|
||||||
if branch == "" {
|
|
||||||
branch = "unknown"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var stop chan struct{}
|
var stop chan struct{}
|
||||||
|
|
||||||
func reloadLoop(
|
func reloadLoop(
|
||||||
|
@ -165,7 +154,7 @@ func reloadLoop(
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
log.Printf("I! Starting Telegraf %s\n", displayVersion())
|
log.Printf("I! Starting Telegraf %s\n", version)
|
||||||
log.Printf("I! Loaded inputs: %s", strings.Join(c.InputNames(), " "))
|
log.Printf("I! Loaded inputs: %s", strings.Join(c.InputNames(), " "))
|
||||||
log.Printf("I! Loaded aggregators: %s", strings.Join(c.AggregatorNames(), " "))
|
log.Printf("I! Loaded aggregators: %s", strings.Join(c.AggregatorNames(), " "))
|
||||||
log.Printf("I! Loaded processors: %s", strings.Join(c.ProcessorNames(), " "))
|
log.Printf("I! Loaded processors: %s", strings.Join(c.ProcessorNames(), " "))
|
||||||
|
@ -225,11 +214,27 @@ func (p *program) Stop(s service.Service) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func displayVersion() string {
|
func formatFullVersion() string {
|
||||||
if version == "" {
|
var parts = []string{"Telegraf"}
|
||||||
return fmt.Sprintf("v%s~%s", nextVersion, commit)
|
|
||||||
|
if version != "" {
|
||||||
|
parts = append(parts, version)
|
||||||
|
} else {
|
||||||
|
parts = append(parts, "unknown")
|
||||||
}
|
}
|
||||||
return "v" + version
|
|
||||||
|
if branch != "" || commit != "" {
|
||||||
|
if branch == "" {
|
||||||
|
branch = "unknown"
|
||||||
|
}
|
||||||
|
if commit == "" {
|
||||||
|
commit = "unknown"
|
||||||
|
}
|
||||||
|
git := fmt.Sprintf("(git: %s %s)", branch, commit)
|
||||||
|
parts = append(parts, git)
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Join(parts, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -273,7 +278,7 @@ func main() {
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
switch args[0] {
|
switch args[0] {
|
||||||
case "version":
|
case "version":
|
||||||
fmt.Printf("Telegraf %s (git: %s %s)\n", displayVersion(), branch, commit)
|
fmt.Println(formatFullVersion())
|
||||||
return
|
return
|
||||||
case "config":
|
case "config":
|
||||||
config.PrintSampleConfig(
|
config.PrintSampleConfig(
|
||||||
|
@ -301,7 +306,7 @@ func main() {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
case *fVersion:
|
case *fVersion:
|
||||||
fmt.Printf("Telegraf %s (git: %s %s)\n", displayVersion(), branch, commit)
|
fmt.Println(formatFullVersion())
|
||||||
return
|
return
|
||||||
case *fSampleConfig:
|
case *fSampleConfig:
|
||||||
config.PrintSampleConfig(
|
config.PrintSampleConfig(
|
||||||
|
|
Loading…
Reference in New Issue