Browse Source

修改服务监听

genlong 1 year ago
parent
commit
07949287d6
6 changed files with 39 additions and 31 deletions
  1. 2 1
      core/run_server.go
  2. 1 0
      global/global.go
  3. 24 23
      go.mod
  4. 2 0
      init_serve/mysql.go
  5. 2 1
      init_serve/redis.go
  6. 8 6
      init_serve/task.go

+ 2 - 1
core/run_server.go

@@ -18,7 +18,6 @@ func RunServe() {
 		//初始化redis
 		init_serve.RedisTool()
 	}
-
 	// 启动任务
 	init_serve.InitTask()
 
@@ -26,5 +25,7 @@ func RunServe() {
 	err := r.Run(fmt.Sprint("0.0.0.0:", global.CONFIG.Serve.Port)) // 监听并在 0.0.0.0:8080 上启动服务
 	if err != nil {
 		panic(fmt.Errorf("服务启动失败,Err:%s", err))
+	} else {
+		fmt.Println("Run:", fmt.Sprint("0.0.0.0:", global.CONFIG.Serve.Port))
 	}
 }

+ 1 - 0
global/global.go

@@ -40,6 +40,7 @@ func init() {
 	}
 
 	fmt.Println("configFilePath->", configFilePath)
+
 	//设置配置文件
 	v.SetConfigFile(configFilePath)
 

+ 24 - 23
go.mod

@@ -1,35 +1,36 @@
 module hongze/hz_crm_eta
 
-go 1.19
+go 1.18
 
 require (
 	github.com/astaxie/beego v1.12.3
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/fsnotify/fsnotify v1.6.0
-	github.com/gin-gonic/gin v1.9.0
+	github.com/gin-gonic/gin v1.9.1
 	github.com/go-playground/locales v0.14.1
 	github.com/go-playground/universal-translator v0.18.1
-	github.com/go-playground/validator/v10 v10.11.2
+	github.com/go-playground/validator/v10 v10.14.0
 	github.com/go-redis/redis/v8 v8.11.5
 	github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
 	github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
 	github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
 	github.com/rdlucklib/rdluck_tools v1.0.3
-	github.com/spf13/viper v1.15.0
+	github.com/spf13/viper v1.16.0
 	github.com/swaggo/swag v1.16.1
-	golang.org/x/image v0.7.0
-	gorm.io/driver/mysql v1.5.0
-	gorm.io/gorm v1.25.0
+	golang.org/x/image v0.9.0
+	gorm.io/driver/mysql v1.5.1
+	gorm.io/gorm v1.25.2
 )
 
 require (
 	github.com/KyleBanks/depth v1.2.1 // indirect
 	github.com/PuerkitoBio/purell v1.1.1 // indirect
 	github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
-	github.com/bytedance/sonic v1.8.0 // indirect
+	github.com/bytedance/sonic v1.9.1 // indirect
 	github.com/cespare/xxhash/v2 v2.1.2 // indirect
 	github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
 	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
+	github.com/gabriel-vasile/mimetype v1.4.2 // indirect
 	github.com/garyburd/redigo v1.6.3 // indirect
 	github.com/gin-contrib/sse v0.1.0 // indirect
 	github.com/go-openapi/jsonpointer v0.19.5 // indirect
@@ -37,39 +38,39 @@ require (
 	github.com/go-openapi/spec v0.20.4 // indirect
 	github.com/go-openapi/swag v0.19.15 // indirect
 	github.com/go-sql-driver/mysql v1.7.0 // indirect
-	github.com/goccy/go-json v0.10.0 // indirect
+	github.com/goccy/go-json v0.10.2 // indirect
 	github.com/hashicorp/hcl v1.0.0 // indirect
 	github.com/jinzhu/inflection v1.0.0 // indirect
 	github.com/jinzhu/now v1.1.5 // indirect
 	github.com/jonboulle/clockwork v0.4.0 // indirect
 	github.com/josharian/intern v1.0.0 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
-	github.com/klauspost/cpuid/v2 v2.0.9 // indirect
-	github.com/leodido/go-urn v1.2.1 // indirect
+	github.com/klauspost/cpuid/v2 v2.2.4 // indirect
+	github.com/leodido/go-urn v1.2.4 // indirect
 	github.com/lestrrat-go/strftime v1.0.6 // indirect
 	github.com/magiconair/properties v1.8.7 // indirect
-	github.com/mailru/easyjson v0.7.7 // indirect
-	github.com/mattn/go-isatty v0.0.17 // indirect
+	github.com/mailru/easyjson v0.7.6 // indirect
+	github.com/mattn/go-isatty v0.0.19 // indirect
 	github.com/mitchellh/mapstructure v1.5.0 // indirect
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
-	github.com/pelletier/go-toml/v2 v2.0.6 // indirect
+	github.com/pelletier/go-toml/v2 v2.0.8 // indirect
 	github.com/pkg/errors v0.9.1 // indirect
 	github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
-	github.com/spf13/afero v1.9.3 // indirect
-	github.com/spf13/cast v1.5.0 // indirect
+	github.com/spf13/afero v1.9.5 // indirect
+	github.com/spf13/cast v1.5.1 // indirect
 	github.com/spf13/jwalterweatherman v1.1.0 // indirect
 	github.com/spf13/pflag v1.0.5 // indirect
 	github.com/subosito/gotenv v1.4.2 // indirect
 	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
-	github.com/ugorji/go/codec v1.2.9 // indirect
-	golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
-	golang.org/x/crypto v0.8.0 // indirect
-	golang.org/x/net v0.9.0 // indirect
-	golang.org/x/sys v0.7.0 // indirect
-	golang.org/x/text v0.9.0 // indirect
+	github.com/ugorji/go/codec v1.2.11 // indirect
+	golang.org/x/arch v0.3.0 // indirect
+	golang.org/x/crypto v0.9.0 // indirect
+	golang.org/x/net v0.10.0 // indirect
+	golang.org/x/sys v0.8.0 // indirect
+	golang.org/x/text v0.11.0 // indirect
 	golang.org/x/tools v0.7.0 // indirect
-	google.golang.org/protobuf v1.28.1 // indirect
+	google.golang.org/protobuf v1.30.0 // indirect
 	gopkg.in/ini.v1 v1.67.0 // indirect
 	gopkg.in/yaml.v2 v2.4.0 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect

+ 2 - 0
init_serve/mysql.go

@@ -70,4 +70,6 @@ func Mysql() {
 
 	//全局赋值数据库链接
 	global.MYSQL = mysqlMap
+
+	fmt.Println("mysql init end")
 }

+ 2 - 1
init_serve/redis.go

@@ -28,7 +28,7 @@ func Redis() {
 }
 
 func RedisTool() {
-	fmt.Println("init RedisTool")
+	fmt.Println("init RedisTool start")
 	redisConf := global.CONFIG.Redis
 	fmt.Println(redisConf)
 	REDIS_CACHE := fmt.Sprintf(`{"key":"redis","conn":"%s","password":"%s"}`, redisConf.Address, redisConf.Password)
@@ -38,4 +38,5 @@ func RedisTool() {
 		fmt.Println(global.Re)
 		panic(global.Re)
 	}
+	fmt.Println("init RedisTool end")
 }

+ 8 - 6
init_serve/task.go

@@ -3,11 +3,13 @@ package init_serve
 import "hongze/hz_crm_eta/services"
 
 func InitTask() {
-	// 监听角色同步
-	services.ListenSyncRoleFromCrm()
-	services.ListenSyncRoleFromEta()
+	go func() {
+		// 监听角色同步
+		services.ListenSyncRoleFromCrm()
+		services.ListenSyncRoleFromEta()
 
-	// 监听用户同步
-	services.ListenSyncAdminFromCrm()
-	services.ListenSyncAdminFromEta()
+		// 监听用户同步
+		services.ListenSyncAdminFromCrm()
+		services.ListenSyncAdminFromEta()
+	}()
 }