forked from go-chassis/go-chassis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtime.go
executable file
·41 lines (34 loc) · 843 Bytes
/
runtime.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package runtime
import (
"github.com/go-chassis/go-chassis/core/config"
"github.com/go-chassis/go-chassis/core/lager"
"os"
)
//Status
const (
StatusRunning = "UP"
StatusDown = "DOWN"
)
//HostName is the host name of service host
var HostName string
//ServiceID is the service id in registry service
var ServiceID string
//InstanceID is the instance id in registry service
var InstanceID string
//InstanceStatus is the current status of instance
var InstanceStatus string
// Init runtime information
func Init() error {
var err error
service := config.MicroserviceDefinition
HostName = service.ServiceDescription.Hostname
if HostName == "" {
HostName, err = os.Hostname()
if err != nil {
lager.Logger.Error("Get hostname failed.", err)
return err
}
}
lager.Logger.Info("Host name is " + HostName)
return nil
}