Commit 299cbfd6 by mushishixian

fix

parents eb23155d 86a35510
...@@ -8,5 +8,6 @@ cmd.exe~ ...@@ -8,5 +8,6 @@ cmd.exe~
/cmd/*.exe~ /cmd/*.exe~
/cmd/logs /cmd/logs
/bat/logs/ /bat/logs/
/conf/*.ini /conf/prod/*.ini
/conf
...@@ -20,8 +20,7 @@ func main() { ...@@ -20,8 +20,7 @@ func main() {
panic(err) panic(err)
} }
logger.Log("dddd","3333",1) logger.Log("启动任务","ratio",1)
ZyCronService := service.ZyCronService{} ZyCronService := service.ZyCronService{}
ZyCronService.ZyDiscount(goods_id) ZyCronService.ZyDiscount(goods_id)
} }
2020-10-13 16:38:11----dddd
\ No newline at end of file
SET CGO_ENABLED=0
SET GOARCH=amd64
SET GOOS=linux
go build -o http http_server.go
SET CGO_ENABLED=1
SET GOARCH=
SET GOOS=windows
package main
import (
"flag"
"github.com/gin-gonic/gin"
"github.com/micro/go-micro/v2/web"
"go_sku_server/boot"
"go_sku_server/pkg/config"
"go_sku_server/routes"
)
func main() {
var path string
flag.StringVar(&path, "config", "conf", "配置文件")
flag.Parse()
if err := boot.Boot(path); err != nil {
panic(err)
}
gin.SetMode(config.Get("web.mode").String())
r := routes.InitRouter()
port := config.Get("web.port").String()
//web改成micro 就是grpc,并直接注册到etcd里面
service := web.NewService(
web.Name("go.micro.api.http.search"),
web.Handler(r),
web.Address(":"+port),
)
if err := service.Init(); err != nil {
panic(err)
}
if err := service.Run(); err != nil {
panic(err)
}
}
;总配置信息 ;总配置信息
[web] [web]
port = 9000 port = 60005
mode = debug mode = debug
cors_domain = http://bom.liexin.com cors_domain = http://bom.liexin.com
......
;总配置信息
[web]
port = 9000
mode = debug
[message]
api_domain = http://api.ichunt.com/msg/sendMessageByAuto
api_md5_str = fh6y5t4rr351d2c3bryi
;钉钉配置信息
[DINGDING]
SEARCH_API_MONITOR = 6d0fa85e01a02c39347d011ae973fd21b76c6c7ce582d3ea470c6b65a318848d
;存放数据库连接信息
[xorm]
ShowSQL = false
[spu]
user_name = LxiCSpu
password = `Mysx3Tyzlo00oxlmlly`
host = 172.18.137.21
database = liexin_spu
table_prefix =lie_
type = mysql
[liexin_data]
user_name = LxDDUsedRead
password = `0o9u0Ux2oAoYddflmxXtZss`
host = 172.18.137.33
database = liexin_data
table_prefix =lie_
type = mysql
[supp]
user_name = SupDbUser
password = `Supssy2@@!!@$#yxy`
host = 172.18.137.21
database = liexin_supp
table_prefix =lie_
type = mysql
[cms]
user_name = dtuser
password = `dAtaL#ym2902m2lLX2y33`
host = appdb-master.ichunt.db
database = icdata
table_prefix =
type = mysql
;存放mongodb连接信息
[mongo]
host = 172.18.137.23:27017
username = "ichunt"
password = "huntmon66499"
database = ichunt
maxPoolSize=100
\ No newline at end of file
;存放rabmq连接信息
[rabmq]
url = amqp://guest:guest@192.168.2.232:5672/
;存放本系统所有的队列名称
[rabmq_all]
; bom任务id
MQ_BOM_ITEMS_LIST=bom_items_list
;redis连接信息
[default_redis_read]
host = 172.18.137.38:6379
password = icDb29mLy2s
max_idle = 500
max_active = 500
idle_timeout = 20
[default_redis_write]
host = 172.18.137.39:6379
password = icDb29mLy2s
max_idle = 500
max_active = 500
idle_timeout = 20
;存放redis所有键
[redis_all]
\ No newline at end of file
...@@ -39,6 +39,7 @@ func Synchronization(ctx *gin.Context) { ...@@ -39,6 +39,7 @@ func Synchronization(ctx *gin.Context) {
common.Output(ctx, 1001, "查询型号ID不得为空", "") common.Output(ctx, 1001, "查询型号ID不得为空", "")
return return
} }
//gjson.Parse(string).Array()
GoodsRes := sync.Map{} GoodsRes := sync.Map{}
...@@ -64,7 +65,6 @@ func Synchronization(ctx *gin.Context) { ...@@ -64,7 +65,6 @@ func Synchronization(ctx *gin.Context) {
if len(lyGoodsId) >= goods_slice_count { if len(lyGoodsId) >= goods_slice_count {
common.PrintDebugHtml(ctx, "ly增加协程:") common.PrintDebugHtml(ctx, "ly增加协程:")
common.PrintDebugHtml(ctx, zyGoodsId) common.PrintDebugHtml(ctx, zyGoodsId)
wg.Add(1) wg.Add(1)
go lyService.LyGoodsDetail(ctx, lyGoodsId, &GoodsRes, &wg) go lyService.LyGoodsDetail(ctx, lyGoodsId, &GoodsRes, &wg)
lyGoodsId = lyGoodsId[:0:0] lyGoodsId = lyGoodsId[:0:0]
...@@ -85,7 +85,6 @@ func Synchronization(ctx *gin.Context) { ...@@ -85,7 +85,6 @@ func Synchronization(ctx *gin.Context) {
wg.Add(1) wg.Add(1)
go lyService.LyGoodsDetail(ctx, lyGoodsId, &GoodsRes, &wg) go lyService.LyGoodsDetail(ctx, lyGoodsId, &GoodsRes, &wg)
} }
wg.Wait() wg.Wait()
//异步map最后转成map //异步map最后转成map
...@@ -95,10 +94,11 @@ func Synchronization(ctx *gin.Context) { ...@@ -95,10 +94,11 @@ func Synchronization(ctx *gin.Context) {
temp[s] = v temp[s] = v
return true return true
}) })
common.Output(ctx, 0, "success", temp) common.Output(ctx, 0, "success", temp)
} }
/* /*
健康监测 健康监测
*/ */
......
...@@ -22,6 +22,7 @@ require ( ...@@ -22,6 +22,7 @@ require (
github.com/ichunt2019/go-rabbitmq v1.0.1 github.com/ichunt2019/go-rabbitmq v1.0.1
github.com/ichunt2019/logger v1.0.5 github.com/ichunt2019/logger v1.0.5
github.com/imroc/req v0.3.0 github.com/imroc/req v0.3.0
github.com/jasonlvhit/gocron v0.0.1 // indirect
github.com/mattn/go-sqlite3 v2.0.1+incompatible // indirect github.com/mattn/go-sqlite3 v2.0.1+incompatible // indirect
github.com/micro/go-micro v1.16.0 github.com/micro/go-micro v1.16.0
github.com/micro/go-micro/v2 v2.9.0 github.com/micro/go-micro/v2 v2.9.0
......
...@@ -4,15 +4,21 @@ ...@@ -4,15 +4,21 @@
一:启动http 对外服务: 一:启动http 对外服务:
cd cmd/http cd cmd/http
go build -o ./http ./http_server.go go build -o ./http ./http_server.go
chmod -R 755 http
chmod +x http
运行-线上: ./http -config=../../conf/prod 运行-线上: ./http -config=../../conf/prod
运行-开发: ./http -config=../../conf/dev 运行-开发: ./http -config=../../conf/dev
二:启动定时任务 二:增加定时任务:
cd cmd/cron cd cmd/cron
go build -o ./cron ./cron_server.go go build -o ./cron ./cron_server.go
增加定时crontab 任务: chmod -R 755 cron
运行-线上: 0 0 */3 * * cd /go_sku_server/cmd/cron/ && ./cron -config=../../conf/prod chmod +x cron
运行-开发: 0 0 */3 * * cd /go_sku_server/cmd/cron/ && ./cron -config=../../conf/dev 运行-线上: ./cron -config=../../conf/prod
运行-开发: ./cron -config=../../conf/dev
一共两个任务,最好都配置supervisor
### 目录结构 ### 目录结构
├── bat //运行脚本或者protoc生成脚本 ├── bat //运行脚本或者protoc生成脚本
......
...@@ -16,6 +16,9 @@ func InitRouter() *gin.Engine { ...@@ -16,6 +16,9 @@ func InitRouter() *gin.Engine {
r.GET("synchronization", controller.Synchronization) r.GET("synchronization", controller.Synchronization)
r.POST("synchronization",controller.Synchronization) r.POST("synchronization",controller.Synchronization)
//联营参数选择搜索
r.GET("Synchronization", controller.Synchronization)
r.POST("Synchronization",controller.Synchronization)
//心跳 //心跳
r.GET("Health", controller.Health) r.GET("Health", controller.Health)
r.POST("Health",controller.Health) r.POST("Health",controller.Health)
......
...@@ -32,7 +32,6 @@ type ZiyingService struct { ...@@ -32,7 +32,6 @@ type ZiyingService struct {
@param power[verify_blacklist] 是否验证黑名单,用于折扣活动提交订单页面与后台下单 :true @param power[verify_blacklist] 是否验证黑名单,用于折扣活动提交订单页面与后台下单 :true
*/ */
func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context,goodsIds []string,goodsRes *sync.Map, wg *sync.WaitGroup) { func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context,goodsIds []string,goodsRes *sync.Map, wg *sync.WaitGroup) {
redisConn := gredis.Conn("search_r") redisConn := gredis.Conn("search_r")
defer func() { defer func() {
wg.Done(); wg.Done();
...@@ -44,7 +43,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context,goodsIds []string,goodsR ...@@ -44,7 +43,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context,goodsIds []string,goodsR
for goods_id,info := range skuArr { for goods_id,info := range skuArr {
if gjson.Get(info, "goods_name").String() == "" { if gjson.Get(info, "goods_name").String() == "" {
fmt.Print("报错1001-----",goods_id,skuArr) fmt.Print("报错redis 1001-----",goods_id,skuArr)
} }
//拼接梯度价格 //拼接梯度价格
......
#适用于更新GOSKU代码服务,并且重启代码
#!/bin/bash
Cur_Dir=$(pwd)
echo $Cur_Dir
cd $Cur_Dir
git reset --hard HEAD
git pull origin master
rm -f ${Cur_Dir}"/cmd/http/http"
export GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
go build -o ${Cur_Dir}"/cmd/http/http" ${Cur_Dir}"/cmd/http/http_server.go"
chmod +x ${Cur_Dir}"/cmd/http/http"
chmod +x ${Cur_Dir}"/update.sh"
echo "更新执行成功"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment