Skip to content

Commit

Permalink
grab hostname via os.Hostname()
Browse files Browse the repository at this point in the history
on my debian lenny os.Getenv("HOSTNAME") is empty
  • Loading branch information
Andre authored and bmizerany committed Jan 31, 2012
1 parent 48fd070 commit 032fc82
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ func Main(clusterName, self, buri, rwsk, rosk string, cl *doozer.Conn, udpConn *
go m.Run()
}

hostname, err := os.Hostname()
if err != nil {
hostname = "unknown"
}

if cl == nil { // we are the only node in a new cluster
set(st, "/ctl/name", clusterName, store.Missing)
set(st, "/ctl/node/"+self+"/addr", listenAddr, store.Missing)
set(st, "/ctl/node/"+self+"/hostname", os.Getenv("HOSTNAME"), store.Missing)
set(st, "/ctl/node/"+self+"/hostname", hostname, store.Missing)
set(st, "/ctl/node/"+self+"/version", Version, store.Missing)
set(st, "/ctl/cal/0", self, store.Missing)
if buri == "" {
Expand All @@ -94,7 +99,7 @@ func Main(clusterName, self, buri, rwsk, rosk string, cl *doozer.Conn, udpConn *
go setReady(pr, self)
} else {
setC(cl, "/ctl/node/"+self+"/addr", listenAddr, store.Clobber)
setC(cl, "/ctl/node/"+self+"/hostname", os.Getenv("HOSTNAME"), store.Clobber)
setC(cl, "/ctl/node/"+self+"/hostname", hostname, store.Clobber)
setC(cl, "/ctl/node/"+self+"/version", Version, store.Clobber)

rev, err := cl.Rev()
Expand Down

0 comments on commit 032fc82

Please sign in to comment.