Merge pull request #201 from captainblue2013/patch-1

fix: 获取hostname的优先级逻辑
pull/205/head
Tony 6 years ago committed by GitHub
commit b73938c8de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      pkg/conf/env/env.go

@ -5,6 +5,8 @@ package env
import (
"flag"
"os"
"strconv"
"time"
)
// deploy env.
@ -45,10 +47,13 @@ var (
func init() {
var err error
if Hostname, err = os.Hostname(); err != nil || Hostname == "" {
Hostname = os.Getenv("HOSTNAME")
Hostname = os.Getenv("HOSTNAME")
if Hostname == "" {
Hostname, err = os.Hostname()
if err != nil {
Hostname = strconv.Itoa(int(time.Now().UnixNano()))
}
}
addFlag(flag.CommandLine)
}

Loading…
Cancel
Save