otto 2 years ago
parent
commit
40e9863d37
  1. 11
      cmd/server/main.go
  2. 2
      cmd/server/wire.go
  3. 7
      cmd/server/wire_gen.go
  4. 28
      configs/config.yaml
  5. 20
      go.mod
  6. 38
      go.sum
  7. 372
      internal/biz/biz.go
  8. 49
      internal/biz/biz_test.go
  9. 19
      internal/biz/configs/config
  10. 42
      internal/biz/configs/config.yaml
  11. 12
      job.yaml

11
cmd/server/main.go

@ -3,10 +3,10 @@ package main
import ( import (
"context" "context"
"flag" "flag"
"fmt"
"git.gz.internal.jumaiyx.cn/pkg/config" "git.gz.internal.jumaiyx.cn/pkg/config"
"git.gz.internal.jumaiyx.cn/pkg/log" "git.gz.internal.jumaiyx.cn/pkg/log"
"os" "os"
"time"
) )
var ( var (
@ -19,20 +19,19 @@ var (
func main() { func main() {
flag.Parse() flag.Parse()
c, err := config.New().Conf("./configs/config.yaml") bc, err := config.NewConfig().Load()
if err != nil { if err != nil {
fmt.Println(err)
panic(err) panic(err)
} }
bc := c.Get()
l := log.DefaultLogger() l := log.DefaultLogger()
biz, cleanup, err := wireApp(bc.Server, l) biz, cleanup, err := wireApp(l, bc.Data, bc.Webhook)
if err != nil { if err != nil {
panic(err) panic(err)
} }
defer cleanup() defer cleanup()
ctx := context.TODO() ctx := context.TODO()
l.WithContext(ctx) l.WithContext(ctx)
biz.Check(ctx) biz.Run(ctx)
time.Sleep(time.Second * 10)
} }

2
cmd/server/wire.go

@ -13,6 +13,6 @@ import (
) )
// wireApp init kratos application. // wireApp init kratos application.
func wireApp(*conf.Server, log.Logger) (*biz.Biz, func(), error) { func wireApp(log.Logger, *conf.Data, *conf.Webhook) (*biz.Biz, func(), error) {
panic(wire.Build(biz.ProviderBizSet)) panic(wire.Build(biz.ProviderBizSet))
} }

7
cmd/server/wire_gen.go

@ -15,8 +15,11 @@ import (
// Injectors from wire.go: // Injectors from wire.go:
// wireApp init kratos application. // wireApp init kratos application.
func wireApp(server *conf.Server, logger log.Logger) (*biz.Biz, func(), error) { func wireApp(logger log.Logger, data *conf.Data, webhook *conf.Webhook) (*biz.Biz, func(), error) {
bizBiz := biz.NewBiz(logger) bizBiz, err := biz.NewBiz(logger, data, webhook)
if err != nil {
return nil, nil, err
}
return bizBiz, func() { return bizBiz, func() {
}, nil }, nil
} }

28
configs/config.yaml

@ -1,8 +1,5 @@
server: server:
name: room name: room
http:
addr: 0.0.0.0:8000
timeout: 30
grpc: grpc:
addr: 0.0.0.0:9000 addr: 0.0.0.0:9000
timeout: 30 timeout: 30
@ -15,28 +12,19 @@ data:
password: MM5ZsXL0 password: MM5ZsXL0
read_timeout: 1 read_timeout: 1
write_timeout: 1 write_timeout: 1
db: 1
etcd:
host: "127.0.0.1:20000"
log: log:
level: "debug" level: "debug"
name: "room" name: "room"
debug: true
kafka: kafka:
addr: addr:
- "127.0.0.1:9092" - "127.0.0.1:9092"
amqp:
host: 192.168.1.156:5672
username: jm
password: jm123456
id_encode:
uid:
salt: "test"
min_length: 8
rtctoken: webhook:
app_id: 6eeb2e6be9a141d1b0db920f36a5a9f3 container_webhook:
app_certificate: 80438856882e4563841d56f3cefeb763 url: "https://open.feishu.cn/open-apis/bot/v2/hook/efcfd750-5609-4e80-9d25-fd2092776686"
privilege_expiration: 3600 keys:
token_expiration: 3600 - "【时长警告】"
- "【成功】"

20
go.mod

@ -3,27 +3,31 @@ module git.gz.internal.jumaiyx.cn/job/room-server-clear
go 1.18 go 1.18
require ( require (
git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20230217083354-fc40467648e7 git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20230410063401-05bb71e90b80
git.gz.internal.jumaiyx.cn/pkg/config v0.0.0-20221014090146-8fd721834886 git.gz.internal.jumaiyx.cn/pkg/config v0.0.0-20230315093842-e0c44caaecfa
git.gz.internal.jumaiyx.cn/pkg/k8s-client v0.0.0-20230213091252-ba02ce8af13a git.gz.internal.jumaiyx.cn/pkg/k8s-client v0.0.0-20230408090535-cf7764ed02b6
git.gz.internal.jumaiyx.cn/pkg/kubediscovery v0.0.0-20221104101240-01cad3403ec0 git.gz.internal.jumaiyx.cn/pkg/log v1.0.0
git.gz.internal.jumaiyx.cn/pkg/log v0.0.0-20230213074339-8fa1e676b686 git.gz.internal.jumaiyx.cn/pkg/webhook v0.0.0-20230404074907-1e358d533fc2
github.com/go-kratos/kratos/v2 v2.5.3
github.com/google/wire v0.5.0 github.com/google/wire v0.5.0
github.com/redis/go-redis/v9 v9.0.3
k8s.io/apimachinery v0.25.4 k8s.io/apimachinery v0.25.4
) )
require ( require (
git.gz.internal.jumaiyx.cn/pkg/kafka v0.0.0-20221118023940-844d051e6449 // indirect git.gz.internal.jumaiyx.cn/pkg/kafka v0.0.0-20221118023940-844d051e6449 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/emicklei/go-restful/v3 v3.10.0 // indirect github.com/emicklei/go-restful/v3 v3.10.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-kratos/kratos/v2 v2.5.3 // indirect
github.com/go-logr/logr v1.2.3 // indirect github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.22.3 // indirect github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-playground/form/v4 v4.2.0 // indirect github.com/go-playground/form/v4 v4.2.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gnostic v0.6.9 // indirect github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect github.com/google/go-cmp v0.5.9 // indirect
@ -34,10 +38,12 @@ require (
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.12 // indirect github.com/klauspost/compress v1.15.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/segmentio/kafka-go v0.4.38 // indirect github.com/segmentio/kafka-go v0.4.38 // indirect
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect
github.com/xdg/scram v1.0.5 // indirect github.com/xdg/scram v1.0.5 // indirect
@ -52,7 +58,7 @@ require (
google.golang.org/appengine v1.6.7 // indirect google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
google.golang.org/grpc v1.51.0 // indirect google.golang.org/grpc v1.51.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect

38
go.sum

@ -1,25 +1,29 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20230217083354-fc40467648e7 h1:s6K3T28drWlvwK+xn4jzs3r9RzXeQvCCCEUdWktk3zU= git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20230410063401-05bb71e90b80 h1:xfAGm/CRAe1Ad53Mv+c1YMykXyW4sgRjCJeHWWWxwKc=
git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20230217083354-fc40467648e7/go.mod h1:U6I+UIgNboy04gVNv6/5azHTSjAJJICfu0vBxTgv3PE= git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20230410063401-05bb71e90b80/go.mod h1:gmKH81QBtq+tq0fRnkaHzWXPQC4kLkdNmBG8153b03I=
git.gz.internal.jumaiyx.cn/pkg/config v0.0.0-20221014090146-8fd721834886 h1:LP4psj3ygJEKL6748ZQPNwYnYPmbo8dDwtwU08coRiw= git.gz.internal.jumaiyx.cn/pkg/config v0.0.0-20230315093842-e0c44caaecfa h1:AFmNuC4k8kHttPH2kg5yfVd/QmZtazqkFxmYoU/82BI=
git.gz.internal.jumaiyx.cn/pkg/config v0.0.0-20221014090146-8fd721834886/go.mod h1:yEnzjNrnPNIr0Zq926QiJrbyReS+VZqX5bmkYhnSV7I= git.gz.internal.jumaiyx.cn/pkg/config v0.0.0-20230315093842-e0c44caaecfa/go.mod h1:RIgQR6o71kVvJlPhjRvpnKoZGWRfgEwa+qaTaQikmiA=
git.gz.internal.jumaiyx.cn/pkg/k8s-client v0.0.0-20230213091252-ba02ce8af13a h1:LE6nlpvHgKnHXuSsPN7WHLjVQxR82TtSJ4HkKo2GJPA= git.gz.internal.jumaiyx.cn/pkg/k8s-client v0.0.0-20230408090535-cf7764ed02b6 h1:ktyzegIyl8FHoBFi08aUZpItLCZjf30DYdJYzt0+lvo=
git.gz.internal.jumaiyx.cn/pkg/k8s-client v0.0.0-20230213091252-ba02ce8af13a/go.mod h1:YLXO2BSKUZ0/RzVdbsBKAeTHDI75/NMCmt8SsB9eeCU= git.gz.internal.jumaiyx.cn/pkg/k8s-client v0.0.0-20230408090535-cf7764ed02b6/go.mod h1:q4NAPdraM7yYlJ6mSw1rvziQrw6ezCs0FWgtgFqZqM0=
git.gz.internal.jumaiyx.cn/pkg/kafka v0.0.0-20221118023940-844d051e6449 h1:kIzpUIKxa9yLZUfgYK+z3uBAzF0BCkauNxhlUEL5n+c= git.gz.internal.jumaiyx.cn/pkg/kafka v0.0.0-20221118023940-844d051e6449 h1:kIzpUIKxa9yLZUfgYK+z3uBAzF0BCkauNxhlUEL5n+c=
git.gz.internal.jumaiyx.cn/pkg/kafka v0.0.0-20221118023940-844d051e6449/go.mod h1:rspqWOZacckvYwl1M6tikwkdsOlorUmt3CylJ3cGQV8= git.gz.internal.jumaiyx.cn/pkg/kafka v0.0.0-20221118023940-844d051e6449/go.mod h1:rspqWOZacckvYwl1M6tikwkdsOlorUmt3CylJ3cGQV8=
git.gz.internal.jumaiyx.cn/pkg/kubediscovery v0.0.0-20221104101240-01cad3403ec0 h1:G3Hb4Bz9Ku3hSkIIZZu33iN+CNqPEnjVbsOa+MVnat4= git.gz.internal.jumaiyx.cn/pkg/log v1.0.0 h1:pofdfRB3of2HWCuUTfw4osU1+itLuSXZmtRbclBR728=
git.gz.internal.jumaiyx.cn/pkg/kubediscovery v0.0.0-20221104101240-01cad3403ec0/go.mod h1:oc2Nm1tO4n09zn9u0KGlQzWzthO5WZ3PPq0CUMCYByg= git.gz.internal.jumaiyx.cn/pkg/log v1.0.0/go.mod h1:PIqzcM0EqQssd5tjEcZQAxRPex0iIOYXnu466T35a84=
git.gz.internal.jumaiyx.cn/pkg/log v0.0.0-20230213074339-8fa1e676b686 h1:aJePiLxITBenCZAP/l6XXAEH7H5WIXQgOO/nmc0WvZU= git.gz.internal.jumaiyx.cn/pkg/webhook v0.0.0-20230404074907-1e358d533fc2 h1:C8N6ooCcDpbkdmEK0HLCukgrxYg6NwJzfsfVPi8OOdU=
git.gz.internal.jumaiyx.cn/pkg/log v0.0.0-20230213074339-8fa1e676b686/go.mod h1:b+W/opUzkHTSFb73EWaqBHWswRp69u1pWac6JWdc9SA= git.gz.internal.jumaiyx.cn/pkg/webhook v0.0.0-20230404074907-1e358d533fc2/go.mod h1:I2L8v9QXo2NFTqHgTdGATxDMZgGkakfvdkkp4TJiQWo=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao=
github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
@ -31,6 +35,8 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWH
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/emicklei/go-restful/v3 v3.10.0 h1:X4gma4HM7hFm6WMeAsTfqA0GOfdNoCzBIkHGoRLGXuM= github.com/emicklei/go-restful/v3 v3.10.0 h1:X4gma4HM7hFm6WMeAsTfqA0GOfdNoCzBIkHGoRLGXuM=
github.com/emicklei/go-restful/v3 v3.10.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/emicklei/go-restful/v3 v3.10.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
@ -71,6 +77,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@ -132,6 +140,8 @@ github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@ -144,9 +154,13 @@ github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q=
github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc= github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc=
github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/redis/go-redis/v9 v9.0.3 h1:+7mmR26M0IvyLxGZUHxu4GiBkJkVDid0Un+j4ScYu4k=
github.com/redis/go-redis/v9 v9.0.3/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/segmentio/kafka-go v0.4.38 h1:iQdOBbUSdfuYlFpvjuALgj7N6DrdPA0HfB4AhREOdtg= github.com/segmentio/kafka-go v0.4.38 h1:iQdOBbUSdfuYlFpvjuALgj7N6DrdPA0HfB4AhREOdtg=
github.com/segmentio/kafka-go v0.4.38/go.mod h1:ikyuGon/60MN/vXFgykf7Zm8P5Be49gJU6vezwjnnhU= github.com/segmentio/kafka-go v0.4.38/go.mod h1:ikyuGon/60MN/vXFgykf7Zm8P5Be49gJU6vezwjnnhU=
@ -300,8 +314,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

372
internal/biz/biz.go

@ -3,241 +3,267 @@ package biz
import ( import (
"context" "context"
"fmt" "fmt"
v1 "git.gz.internal.jumaiyx.cn/jm/jmproto/room/v1" "git.gz.internal.jumaiyx.cn/jm/jmproto/conf"
"git.gz.internal.jumaiyx.cn/job/room-server-clear/internal/util" containerv1 "git.gz.internal.jumaiyx.cn/jm/jmproto/container/v1"
k8s_client "git.gz.internal.jumaiyx.cn/pkg/k8s-client" "git.gz.internal.jumaiyx.cn/pkg/config"
"git.gz.internal.jumaiyx.cn/pkg/k8s-client/deployment" k8sclient "git.gz.internal.jumaiyx.cn/pkg/k8s-client"
"git.gz.internal.jumaiyx.cn/pkg/k8s-client/service" "git.gz.internal.jumaiyx.cn/pkg/k8s-client/pod"
"git.gz.internal.jumaiyx.cn/pkg/log" "git.gz.internal.jumaiyx.cn/pkg/log"
"git.gz.internal.jumaiyx.cn/pkg/webhook"
"github.com/go-kratos/kratos/v2/transport/grpc" "github.com/go-kratos/kratos/v2/transport/grpc"
"github.com/google/wire" "github.com/google/wire"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/redis/go-redis/v9"
"strings" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sync" "os"
"time" "time"
) )
const ( const (
limit = 100 redisKey = "container:monitor:%s"
outTime = 10 limit = 2
//outTime = int64(86400) * 1
outTime = int64(86400) * 3
wOutTime = int64(86400) * 7
//wOutTime = int64(86400) * 7
) )
var wg sync.WaitGroup var Exclude = []string{"room-server-3-0-20230407163627"}
// ProviderBizSet is biz providers. // ProviderBizSet is biz providers.
var ProviderBizSet = wire.NewSet(NewBiz) var ProviderBizSet = wire.NewSet(NewBiz)
type PodData struct { func NewRedis(c *conf.Data) *redis.Client {
RoomId int64 dataRedis := c.Redis
BranchId int64 return redis.NewClient(&redis.Options{
Name string DB: int(dataRedis.Db),
StartTime string Addr: dataRedis.Addr,
Username: dataRedis.Username,
Password: dataRedis.Password,
})
} }
type Biz struct { func NewPod(logger log.Logger) (pod.PodRepo, error) {
log log.Logger return k8sclient.Pod(k8sclient.Overview{
depChan chan []PodData Namespace: k8sclient.UnityNamespace,
serChan chan []PodData Log: logger,
deploy deployment.Deployment })
ser service.Service
} }
func NewBiz(logger log.Logger) *Biz { type Data struct {
return &Biz{ Name string
log: logger, Second int64
depChan: make(chan []PodData, 1),
serChan: make(chan []PodData, 1),
}
} }
func (biz *Biz) roomServerClient(ctx context.Context) (v1.RoomClient, error) { type Biz struct {
//discovery, err := kubediscovery.Discovery(ctx, biz.log, base.RoomServiceName, kubediscovery.Namespace(k8s_client.DevNamespace)) logger log.Logger
discovery, err := grpc.DialInsecure(ctx, grpc.WithEndpoint("127.0.0.1:9000"), grpc.WithTimeout(10*time.Second)) redisClient *redis.Client
pod pod.PodRepo
if err != nil { webhookConf *conf.Webhook
biz.log.Errorf("room client failed:%v", err) nameCh chan []Data
return nil, err flagCh chan bool
}
return v1.NewRoomClient(discovery), nil
} }
// Check func NewBiz(logger log.Logger, data *conf.Data, webhookConf *conf.Webhook) (*Biz, error) {
// 定期删除unity的空置容器 newPod, err := NewPod(logger)
func (biz *Biz) Check(ctx context.Context) {
deploy, err := k8s_client.NewDeployment(k8s_client.UnityNamespace, biz.log)
if err != nil {
biz.log.Errorf("Service connect failed:%v", err)
return
}
biz.deploy = deploy
serice, err := k8s_client.NewService(k8s_client.UnityNamespace, biz.log)
if err != nil { if err != nil {
biz.log.Errorf("Service connect failed:%v", err) return nil, err
return
} }
biz.ser = serice return &Biz{logger: logger, redisClient: NewRedis(data), pod: newPod, webhookConf: webhookConf, nameCh: make(chan []Data, 1), flagCh: make(chan bool, 1)}, nil
wg.Add(4) }
go func() {
defer wg.Done()
biz.deployment(ctx)
return
}()
go func() {
defer wg.Done()
biz.deploymentDel(ctx)
return
}()
go func() {
defer wg.Done()
biz.service(ctx)
}()
// Run 执行检测
func (biz *Biz) Run(ctx context.Context) {
go func() { go func() {
defer wg.Done() biz.Room(ctx)
biz.serviceDel(ctx)
}() }()
continueToken := ""
wg.Wait()
}
// 获取unity的deployment
func (biz *Biz) deployment(ctx context.Context) {
var cont string
for { for {
rsp, err := biz.deploy.List(ctx, metav1.ListOptions{ pods, err := biz.pod.List(ctx, v1.ListOptions{
Limit: limit, Limit: limit,
Continue: cont, Continue: continueToken,
}) })
if err != nil { if err != nil {
biz.log.Errorf("get deployment fail:%v", err) biz.logger.Error(err)
return break
} }
var nameList []Data
for _, p := range pods.Items {
name := p.Name[:31]
result, err := biz.redisClient.Get(ctx, fmt.Sprintf(redisKey, name)).Result()
if err != nil {
biz.logger.Error(err)
}
if result != "" {
continue
}
var flag bool
for _, e := range Exclude {
if e == name {
flag = true
}
}
if flag {
continue
}
s := time.Now().Unix() - p.Status.StartTime.Time.Unix()
var podDatas []PodData if s > outTime {
for _, item := range rsp.Items { nameList = append(nameList, Data{
names := strings.Split(item.Name, "-") Name: name,
podDatas = append(podDatas, PodData{ Second: s,
Name: item.Name, })
RoomId: util.StringTarnsInt64(names[3]), //_, err = biz.redisClient.Set(ctx, fmt.Sprintf(redisKey, p.Name), "1", time.Duration(wOutTime-s)*time.Second).Result()
BranchId: util.StringTarnsInt64(names[4]), //if err != nil {
StartTime: names[5], // biz.logger.Error(err)
}) //}
}
} }
if len(nameList) != 0 {
if len(podDatas) > 0 { biz.nameCh <- nameList
biz.depChan <- podDatas
} }
cont = rsp.Continue continueToken = pods.Continue
if cont == "" { if continueToken == "" {
break break
} }
} }
return biz.flagCh <- true
} }
func (biz *Biz) deploymentDel(ctx context.Context) { func (biz *Biz) Room(ctx context.Context) {
for { for {
select { select {
case pods := <-biz.depChan: case dataList := <-biz.nameCh:
var ids []int64 if len(dataList) == 0 {
for _, pod := range pods { break
ids = append(ids, pod.RoomId)
} }
roomMap, err := biz.roomList(ctx, ids) var nameList []string
for _, data := range dataList {
nameList = append(nameList, data.Name)
}
client, err := biz.containerClient(ctx)
if err != nil { if err != nil {
biz.log.Errorf("get room list fail:%v", err) biz.logger.Error(err)
break
}
containerListRsp, err := client.GetContainerList(ctx, &containerv1.GetContainerListReq{
NameList: nameList,
})
if err != nil {
biz.logger.Error(err)
break
} }
for _, pod := range pods { containerMap := make(map[string]*containerv1.ContainerData, len(containerListRsp.List))
if _, ok := roomMap[pod.RoomId]; !ok { for _, data := range containerListRsp.List {
fmt.Println(pod.Name) containerMap[data.Name] = data
biz.deploy.Delete(ctx, pod.Name) }
for _, v := range dataList {
data, ok := containerMap[v.Name]
if ok {
roomId := int64(0)
if data.Params != nil {
roomId = data.Params.RoomId
}
biz.webhook(v.Name, v.Second, roomId, false)
} else {
//biz.webhook(v.Name, v.Second, 0, true)
} }
} }
case <-time.After(time.Second * outTime): case <-biz.flagCh:
//flag = true
return return
} }
//if flag {
// return
//}
} }
} }
// 获取unity的service func (biz *Biz) containerClient(ctx context.Context) (containerv1.ContainerClient, error) {
func (biz *Biz) service(ctx context.Context) { //discovery, err := register.Discovery(ctx, biz.logger, base.ContainerServiceName, register.WithTimeout(time.Second*10))
var cont string discovery, err := grpc.DialInsecure(
for { ctx,
rsp, err := biz.ser.List(ctx, metav1.ListOptions{ grpc.WithEndpoint("127.0.0.1:9000"),
Limit: limit, grpc.WithTimeout(30*time.Second),
Continue: cont, )
if err != nil {
biz.logger.Errorf("configure client failed:%v", err)
return nil, err
}
return containerv1.NewContainerClient(discovery), nil
}
func (biz *Biz) webhook(name string, s int64, roomId int64, f bool) {
go func() {
env := os.Getenv(config.JmEnvironment)
if env == "" {
env = "dev"
}
var elements []webhook.InteractiveElementsBody
elements = append(elements, webhook.InteractiveElementsBody{
Tag: webhook.InteractiveTagDiv,
Text: &webhook.InteractiveText{
Tag: webhook.InteractiveTagPlainText,
Content: "容器名称:" + name + "\n",
},
}) })
if err != nil { elements = append(elements, webhook.InteractiveElementsBody{
biz.log.Errorf("get deployment fail:%v", err) Tag: webhook.InteractiveTagDiv,
return Text: &webhook.InteractiveText{
Tag: webhook.InteractiveTagPlainText,
Content: "运行环境:" + env + "\n",
},
})
d, h, m := biz.shi(s)
elements = append(elements, webhook.InteractiveElementsBody{
Tag: webhook.InteractiveTagDiv,
Text: &webhook.InteractiveText{
Tag: webhook.InteractiveTagPlainText,
Content: fmt.Sprintf("运行时长:%d天%d时%d分\n", d, h, m),
},
})
room := "关联房间:无\n"
if roomId == 0 {
room = fmt.Sprintf("关联房间:%d\n", roomId)
} }
var podDatas []PodData if f {
for _, item := range rsp.Items { room = "关联房间:容器数据不存在\n"
names := strings.Split(item.Name, "-")
podDatas = append(podDatas, PodData{
Name: item.Name,
RoomId: util.StringTarnsInt64(names[3]),
BranchId: util.StringTarnsInt64(names[4]),
StartTime: names[5],
})
} }
biz.serChan <- podDatas elements = append(elements, webhook.InteractiveElementsBody{
cont = rsp.Continue Tag: webhook.InteractiveTagDiv,
if cont == "" { Text: &webhook.InteractiveText{
break Tag: webhook.InteractiveTagPlainText,
Content: room,
},
})
color := webhook.GeneralColor
if s >= outTime {
color = webhook.WarnColor
} }
} webhook.InteractivePush(biz.webhookConf.ContainerWebhook.Url, webhook.CardContent("容器时长提醒", color, elements...))
return }()
} }
func (biz *Biz) serviceDel(ctx context.Context) { func (biz *Biz) shi(s int64) (d, h, m int64) {
for {
select {
case pods := <-biz.serChan:
var ids []int64
for _, pod := range pods {
ids = append(ids, pod.RoomId)
}
roomMap, err := biz.roomList(ctx, ids)
if err != nil {
biz.log.Errorf("get room list fail:%v", err)
}
for _, pod := range pods { d, s = biz.yu(s, 86400)
if _, ok := roomMap[pod.RoomId]; !ok {
biz.ser.Delete(ctx, pod.Name)
}
}
case <-time.After(time.Second * outTime):
return
}
}
}
// 查看房间信息 if s != 0 && s > 3600 {
func (biz *Biz) roomList(ctx context.Context, ids []int64) (map[int64]int32, error) { h, s = biz.yu(s, 3600)
client, err := biz.roomServerClient(ctx)
if err != nil {
biz.log.Errorf("room server client fail:%v", err)
return nil, err
} }
rsp, err := client.GetRoomList(ctx, &v1.GetRoomListRequest{ if s != 0 && s > 60 {
Ids: ids, m, s = biz.yu(s, 60)
Status: int32(v1.RoomStatus_RoomStatusUp),
})
if err != nil {
return nil, err
} }
items := make(map[int64]int32) return
for _, item := range rsp.Data { }
items[item.RoomId] = 1
} func (biz *Biz) yu(s int64, d int64) (m int64, c int64) {
return items, nil m = s / d
c = s % d
return
} }

49
internal/biz/biz_test.go

@ -1,49 +0,0 @@
package biz
import (
"context"
"git.gz.internal.jumaiyx.cn/pkg/log"
"testing"
"time"
)
func TestNewBiz(t *testing.T) {
time.Sleep(time.Second * 30)
}
func TestCheck(t *testing.T) {
l := log.DefaultLogger()
build := NewBiz(l)
build.Check(context.TODO())
}
func TestNewBiz_Deployment(t *testing.T) {
l := log.DefaultLogger()
build := NewBiz(l)
wg.Add(2)
go func() {
defer wg.Done()
build.deployment(context.TODO())
}()
go func() {
defer wg.Done()
build.deploymentDel(context.TODO())
}()
wg.Wait()
}
func TestNewBiz_Service(t *testing.T) {
l := log.DefaultLogger()
build := NewBiz(l)
wg.Add(2)
go func() {
defer wg.Done()
build.service(context.TODO())
}()
go func() {
defer wg.Done()
build.serviceDel(context.TODO())
}()
wg.Wait()
}

19
internal/biz/configs/config

@ -1,19 +0,0 @@
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lH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VdWdmp2TGw1TDAwL201MDNNZTViREEydVEKSjdPa1dENGtiL2Rob0paQjdaOWZId0tWaTgxYUkxNm9ERlAwbTR5YWQvckZBS3FHUlcxdVpLTXNYK29JL0ttVApVcHp0QStzSXhZZXlBK1VaSXJoN1NjSkZ3amVHdE1YUkJIM0RRUzRZc05SdHkxUnZjUnJXSk1uU3Z1MD0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
server: https://192.168.1.156:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: kubernetes-admin
name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJTFV6blJtKzZqUkV3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TWpBNU1qY3dNVE0wTXpsYUZ3MHlNekE1TWpjd01UTTBOREJhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQTNYOFZrc2x3N3AxQUF3aG4KbW5nRHU3NWRUUUpXUm1EN014a3ZPN0ZiWFFXVTVHUDg3bHpEV2pMeUt2L1NqZTZ5a1VTTkE5Z21kTmRrOTY0RgpnYWpyRnRHSUZXVzM2NVFXeitRT25ZVWFHQk9VRHQ2VFloOWlSRXJIRjhsR3NRVW0vVi9NemttMXpkY284ZEtHCm5VbktDWDhyMW5yVm53UkRiRTE2VEozcFRhK2tXdmVHYlFoRW5PZHpBMkJFTDl3cWR4bUljNm1GMnFla0ZDVXoKMlF1cGtMR3JOMlBEVGd2YmdwcS9pbTdldUIyYXNLczE2RjBy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mJJYnNEbEZEckt0bGdQQWpOVTFOdFd0RU9tUFY1UlBxUDdzaGxEZk1qNmRWNTlzZ0dxVEdRCmtKU01oczE1ekJJcURPNVVNeFpZbTlrcUczSE1EQ0NCVlFJVXEwa0NnWUJtMWRFb0p2QUo5anp0bEczTzFmelkKV291VHNSL0RvV0tMVkI1WWx1cjloaDFRTmp1RHNNK211ckx6UTRDMVZZQkxMTnBGWHcyUXM0ZkloemFJbHYvdQpRN3k3L1FvNEdmUlE4Yzl4YlBHcjlMV1oyeTNqQWZ1ZlFjK3p5bmlrZml1T1ZCRmZZM0NRenAvUTUzQitLa0x0Cnk1SVMzZFA4eEF0NVl1TmE4WDBtSVFLQmdRQ2RBSkFaQlNGZi9yN05uVEJnY3M2MEo2cG55TW1BSitoSkN5WnoKYVpIUzgrOXl4SFhPaThQYlphdHhmMmJYQ2tEUFp2ZFk3MGErUEswTmJSdzhGUUZRbXF6ckFDVTNCOXJ5NDUraAplbkRXR0Racy9Rakd3QytYOHZNbUFvNHdBanhHbVJ2b01kWjFtN0RNbW1lTzZKQ1ZrNnNRd1BRclNVVk9PRGdVCmgyRWJNUUtCZ0RQamNEdjN6SjJJVjFrY01kbjNEMWVyQjBFR0I1M2NYeHFoa0pET3Rqd3RUV3V2dHNIYzI0R3gKNmFQODI1QllUV2NQNEJ6dEFIN1A5RkE2QmlBa0t3T3lrWFR5dDg2RTBUZUM5L3FtSW9EY255aHdReHVCZlB3UQo2bVhxeVFLZFBOTnVoKzlReDBEcGxHMTkzVTFid0pya3k3b3hKc0dackg1OUdGK3VTT3J0Ci0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==

42
internal/biz/configs/config.yaml

@ -1,42 +0,0 @@
server:
name: room
http:
addr: 0.0.0.0:8000
timeout: 30
grpc:
addr: 0.0.0.0:9000
timeout: 30
data:
database:
source: "host=192.168.1.156 user=metachat password=metachat dbname=feedback port=15433 sslmode=disable TimeZone=Asia/Shanghai"
# source: postgresql://metachat:metachat@127.0.0.1:15432/room
redis:
addr: 192.168.1.156:16378
password: MM5ZsXL0
read_timeout: 1
write_timeout: 1
etcd:
host: "127.0.0.1:20000"
log:
level: "debug"
name: "room"
kafka:
addr:
- "127.0.0.1:9092"
amqp:
host: 192.168.1.156:5672
username: jm
password: jm123456
id_encode:
uid:
salt: "test"
min_length: 8
rtctoken:
app_id: 6eeb2e6be9a141d1b0db920f36a5a9f3
app_certificate: 80438856882e4563841d56f3cefeb763
privilege_expiration: 3600
token_expiration: 3600

12
job.yaml

@ -1,20 +1,24 @@
apiVersion: batch/v1beta1 apiVersion: batch/v1beta1
kind: CronJob kind: CronJob
metadata: metadata:
name: room-hot-compute-job name: monitor-container-job
namespace: dev namespace: unity
spec: spec:
schedule: "*/1 * * * *" schedule: "0 5 * * *"
jobTemplate: jobTemplate:
spec: spec:
template: template:
spec: spec:
containers: containers:
- name: room-hot-compute-job - name: monitor-container-job
image: registry.internal.jumaiyx.cn/job/room-server-clear:1 image: registry.internal.jumaiyx.cn/job/room-server-clear:1
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
command: command:
- ./server - ./server
env:
- name: JM_ENVIRONMENT
value: dev
restartPolicy: OnFailure restartPolicy: OnFailure
imagePullSecrets: imagePullSecrets:
- name: registry-harbor - name: registry-harbor
Loading…
Cancel
Save