feat: if service can not found fqdn, replace fqdn with hostname (#1435)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
f68ce30f26
commit
9eaf08a193
|
|
@ -17,7 +17,11 @@
|
|||
package fqdn
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/Showmax/go-fqdn"
|
||||
|
||||
logger "d7y.io/dragonfly/v2/internal/dflog"
|
||||
)
|
||||
|
||||
var FQDNHostname string
|
||||
|
|
@ -29,9 +33,15 @@ func init() {
|
|||
// Get FQDN hostname
|
||||
func fqdnHostname() string {
|
||||
fqdn, err := fqdn.FqdnHostname()
|
||||
if err != nil {
|
||||
logger.Warnf("can not found fqdn: %s", err.Error())
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return hostname
|
||||
}
|
||||
|
||||
return fqdn
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue