作者 yangfu

k8s

[dev]
#数据库相关
data_source = "root:123456@tcp(127.0.0.1:3306)/opportunity?loc=Local"
#data_source = "root:sutianxia2015@tcp(115.29.205.99:3306)/ability_display"
#data_source = "root:root@tcp(localhost:3306)/ability_display?loc=Local"
mysql_user = "${MYSQL_USER||root}"
mysql_password = "${MYSQL_PASSWORD||123456}"
mysql_host = "${MYSQL_HOST||192.168.100.102}"
mysql_port = "${MYSQL_PORT||3306}"
mysql_db_name = "${MYSQL_DB_NAME||opportunity}"
#日志
log_level = "${LOG_LEVEL||debug}"
aliyun_logs_access ="app.log"
#redis相关配置
redis_add_port = "127.0.0.1:6379"
redis_add_port = "192.168.100.102:6379"
redis_auth = "123456"
#sms相关配置
... ... @@ -14,8 +21,8 @@ yunpian_app_key ="0bf6fb10a11a68a95dee80901eb545b5"
#存储 http://ability.fjmaimaimai.com:8080/
source_host ="http://192.168.139.131:8080/"
source_virtual_path=file/ab
source_path =/home/tiptok/www/ab
source_virtual_path=file/opp
source_path =/www/opp
#网易云信 IM
net_im_base_url ="https://api.netease.im/nimserver"
... ...
[prod]
#数据库相关
data_source = "root:123456@tcp(192.168.100.102:3306)/ability_display?loc=Local"
mysql_user = "${MYSQL_USER||root}"
mysql_password = "${MYSQL_PASSWORD||123456}"
mysql_host = "${MYSQL_HOST||192.168.100.102}"
mysql_port = "${MYSQL_PORT||3306}"
mysql_db_name = "${MYSQL_DB_NAME||opportunity}"
#日志
log_level = "${LOG_LEVEL||debug}"
aliyun_logs_access ="app.log"
#redis相关配置
... ... @@ -13,8 +21,8 @@ yunpian_app_key ="0bf6fb10a11a68a95dee80901eb545b5"
#存储 http://ability.fjmaimaimai.com:8080/
source_host ="http://192.168.139.131:8080/"
source_virtual_path=file/ab
source_path =/home/tiptok/www/ab
source_virtual_path=file/opp
source_path =/www/opp
#网易云信 IM
net_im_base_url ="https://api.netease.im/nimserver"
... ...
package utils
import "github.com/astaxie/beego"
func init() {
logLevelMap := make(map[string]int)
logLevelMap["debug"] = beego.LevelDebug
logLevelMap["info"] = beego.LevelInformational
logLevelMap["warn"] = beego.LevelWarning
logLevelMap["error"] = beego.LevelError
logLevelMap["fatal"] = beego.LevelEmergency
}
func ResolveLogLevel(level string) int {
switch level {
case "debug":
return beego.LevelDebug
case "info":
return beego.LevelInformational
case "warn":
return beego.LevelWarning
case "error":
return beego.LevelError
case "fatal":
return beego.LevelEmergency
}
return beego.LevelInformational
}
... ...
package main
import (
"fmt"
"github.com/astaxie/beego"
_ "github.com/go-sql-driver/mysql"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/common"
... ... @@ -10,6 +11,7 @@ import (
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/redis"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/websocket"
"opp/controllers"
"opp/internal/utils"
"opp/protocol"
_ "opp/routers"
"opp/services/im"
... ... @@ -19,23 +21,30 @@ import (
func init() {
time.Local = time.FixedZone("CST", 3600*8)
log.InitLog(config.Logger{
Filename: "app.log",
Level: "7",
})
//TODO:kafka配置
log.InitKafkaLogger(log.KafkaConfig{
Topic: "ability",
Addrs: []string{"127.0.0.1:9092"},
Level: 6,
Filename: beego.AppConfig.String("aliyun_logs_access"),
Level: fmt.Sprintf("%v", utils.ResolveLogLevel(beego.AppConfig.String("log_level"))),
})
//TODO:kafka log配置
//log.InitKafkaLogger(log.KafkaConfig{
// Topic: "ability",
// Addrs: []string{"127.0.0.1:9092"},
// Level: 6,
//})
err := redis.InitWithDb(100, beego.AppConfig.String("redis_add_port"), beego.AppConfig.String("redis_auth"), "0")
if err != nil {
log.Fatal(err, beego.AppConfig.String("redis_add_port"), beego.AppConfig.String("redis_auth"))
//panic(err)
}
dataSource := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?loc=Asia%%2FShanghai",
beego.AppConfig.String("mysql_user"),
beego.AppConfig.String("mysql_password"),
beego.AppConfig.String("mysql_host"),
beego.AppConfig.String("mysql_port"),
beego.AppConfig.String("mysql_db_name"),
)
orm.NewBeeormEngine(config.Mysql{
//AliasName: "default",
DataSource: beego.AppConfig.String("data_source"),
DataSource: dataSource,
MaxIdle: 100,
MaxOpen: 100,
})
... ...