Ocean/Tools/Init.go
Thorsten Sommer a007db1b79 Bug fixes and improvements
+ Add a function to the Tools package to provide the local IP address
and port
+ Add a function to the Tools package to provide a time as formated
string as yyyyMMdd hhmmss.fff
+ Improved the ICCC startup message: Now, the message contains the IP
address and port of the stared server
+ Add a new configuration to specific the necessary Ocean servers' port
(internally, not the public port)
+ The template package reports now which version out of the grid FS is
used.
+ The Ocean server is now bound to the correct IP address and port
(rule: the local IP address!)
+ The order of the system shutdown handlers were wrong!
+ The early ICCC messages problem is now fixed!
+ Fixed an ICCC bug for the case, that a message does not have any
payload!
+ Also the configuration database uses now the correct mgo MongoDB rules
(SetSafe & SetMode)
2014-06-08 11:35:01 +02:00

33 lines
1015 B
Go

package Tools
import "os"
import "time"
import "math/rand"
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
import "github.com/SommerEngineering/Ocean/Log"
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
func init() {
// Get this hostname:
if hostText, errHost := os.Hostname(); errHost != nil {
panic(`Was not able to read the hostname: ` + errHost.Error())
} else {
hostname = hostText
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameCONFIGURATION, `Log the hostname of this machine.`, hostname)
}
// Get all IP addresses:
initIPAddresses4ThisHost()
// Read the InternalCommPassword:
internalCommPassword = ConfigurationDB.Read(`InternalCommPassword`)
// Set the seed for random:
rand.Seed(time.Now().Unix())
// Build the local IP address and port:
allHostsIPAddresses := ReadAllIPAddresses4ThisHost()
port := ConfigurationDB.Read(`OceanServerPort`)
localIPAddressAndPort = allHostsIPAddresses[0] + `:` + port
}