+
+func (setting *Configuration) Check() {
+ // Configuration.Service
+ if setting.Service.IP == "" {
+ setting.Service.IP = "0.0.0.0"
+ }
+ if setting.Service.Port <= 0 {
+ setting.Service.Port = 9000
+ }
+ if setting.Service.ServerName == "" {
+ setting.Service.ServerName = fmt.Sprintf("%v://%v:%v", "http", setting.Service.IP, setting.Service.Port)
+ }
+ if setting.Service.SystemName == "" {
+ setting.Service.SystemName = fmt.Sprintf("%v://%v", "http", setting.Service.IP)
+ }
+ if setting.Service.PublicName == "" {
+ setting.Service.PublicName = setting.Service.ServerName
+ }
+ if setting.Service.ServicePath == "" {
+ setting.Service.ServicePath = "/wservice"
+ }
+ if setting.Service.DataDirectory == "" {
+ setting.Service.DataDirectory = "/data/uzoombox/cloud"
+ }
+ if filepath.Dir(setting.Service.DataDirectory) == "." {
+ setting.Service.DataDirectory = filepath.Join(models.AppDir, setting.Service.DataDirectory)
+ }
+ if len(setting.Service.TrustedProxies) == 0 {
+ setting.Service.TrustedProxies = append(setting.Service.TrustedProxies, "127.0.0.1")
+ }
+
+ // // Configuration.System
+ if setting.System.DBDriver == "" {
+ setting.System.DBDriver = "postgres"
+ }
+ if setting.System.DBHost == "" {
+ setting.System.DBHost = "127.0.0.1"
+ }
+ if setting.System.DBPort <= 0 {
+ setting.System.DBPort = 5432
+ }
+ if setting.System.DBUser == "" {
+ setting.System.DBUser = "postgres"
+ }
+ if setting.System.DBPassword == "" {
+ setting.System.DBPassword = "postgres"
+ }
+ if setting.System.DBName == "" {
+ setting.System.DBName = "smartdb"
+ }
+ if setting.System.Heartbeat <= 0 {
+ setting.System.Heartbeat = 604800 // 7 days
+ }
+ setting.System.IdleTime = (setting.System.Heartbeat << 2)
+ if setting.System.IdleTime <= 0 {
+ setting.System.IdleTime = (3600 << 2)
+ }
+ setting.System.CheckTime = (setting.System.Heartbeat >> 1)
+ if setting.System.CheckTime <= 0 {
+ setting.System.CheckTime = (3600 >> 1)
+ }
+
+ // Configuration.GZip
+ if setting.GZip.Enable {
+ setting.GZip.Enable = true
+ }
+ if setting.GZip.Level == 0 {
+ setting.GZip.Level = gzip.DefaultCompression
+ }
+
+ // Configuration.Logging
+ if setting.Logging.Level == "" {
+ setting.Logging.Level = "info"
+ }
+ if setting.Logging.Prefix == "" {
+ setting.Logging.Prefix = ""
+ }
+ if setting.Logging.File.Name == "" {
+ setting.Logging.File.Name = "server.log"
+ }
+ if !setting.Logging.Syslog.Enable {
+ setting.Logging.Syslog.Enable = false
+ }
+}