mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-05 03:42:08 +08:00
refactor
This commit is contained in:
parent
636d5c6046
commit
cc93391796
2
.env
2
.env
@ -6,7 +6,7 @@ KAFKA_IMAGE=bitnami/kafka:3.5.1
|
||||
MINIO_IMAGE=minio/minio:RELEASE.2024-01-11T07-46-16Z
|
||||
|
||||
|
||||
OPENIM_WEB_IMAGE=ghcr.io/openimsdk/openim-web:v3.5.0-docker
|
||||
OPENIM_WEB_FRONT_IMAGE=ghcr.io/openimsdk/openim-web:v3.5.0-docker
|
||||
OPENIM_ADMIN_FRONT_IMAGE=ghcr.io/openimsdk/openim-admin:toc-base-open-docker.35
|
||||
|
||||
DATA_DIR=./
|
||||
|
||||
@ -61,7 +61,6 @@ services:
|
||||
image: "${KAFKA_IMAGE}"
|
||||
container_name: kafka
|
||||
restart: always
|
||||
user: root
|
||||
ports:
|
||||
- "19094:9094"
|
||||
volumes:
|
||||
@ -100,18 +99,18 @@ services:
|
||||
networks:
|
||||
- openim
|
||||
|
||||
openim-web:
|
||||
image: ${OPENIM_WEB_IMAGE}
|
||||
container_name: openim-web
|
||||
openim-web-front:
|
||||
image: ${OPENIM_WEB_FRONT_IMAGE}
|
||||
container_name: openim-web-front
|
||||
restart: always
|
||||
ports:
|
||||
- "11001:80"
|
||||
networks:
|
||||
- openim
|
||||
|
||||
openim-admin:
|
||||
openim-admin-front:
|
||||
image: ${OPENIM_ADMIN_FRONT_IMAGE}
|
||||
container_name: openim-admin
|
||||
container_name: openim-admin-front
|
||||
restart: always
|
||||
ports:
|
||||
- "11002:80"
|
||||
@ -119,56 +118,3 @@ services:
|
||||
- openim
|
||||
|
||||
|
||||
|
||||
# prometheus:
|
||||
# image: prom/prometheus
|
||||
# container_name: prometheus
|
||||
# hostname: prometheus
|
||||
# restart: always
|
||||
# volumes:
|
||||
# - "${DATA_DIR:-./}/config/instance-down-rules.yml:/etc/prometheus/instance-down-rules.yml"
|
||||
# - "${DATA_DIR:-./}/config/prometheus.yml:/etc/prometheus/prometheus.yml"
|
||||
# ports:
|
||||
# - "${PROMETHEUS_PORT:-19090}:9090"
|
||||
# networks:
|
||||
# server:
|
||||
# ipv4_address: ${PROMETHEUS_NETWORK_ADDRESS:-172.28.0.10}
|
||||
|
||||
# alertmanager:
|
||||
# image: prom/alertmanager
|
||||
# container_name: alertmanager
|
||||
# hostname: alertmanager
|
||||
# restart: always
|
||||
# volumes:
|
||||
# - ${DATA_DIR:-./}/config/alertmanager.yml:/etc/alertmanager/alertmanager.yml
|
||||
# - ${DATA_DIR:-./}/config/email.tmpl:/etc/alertmanager/email.tmpl
|
||||
# ports:
|
||||
# - "${ALERT_MANAGER_PORT:-19093}:9093"
|
||||
# networks:
|
||||
# server:
|
||||
# ipv4_address: ${ALERT_MANAGER_NETWORK_ADDRESS:-172.28.0.14}
|
||||
|
||||
# grafana:
|
||||
# image: grafana/grafana
|
||||
# container_name: grafana
|
||||
# hostname: grafana
|
||||
# user: root
|
||||
# restart: always
|
||||
# ports:
|
||||
# - "${GRAFANA_PORT:-13000}:3000"
|
||||
# volumes:
|
||||
# - "${DATA_DIR:-./}/components/grafana:/var/lib/grafana"
|
||||
# networks:
|
||||
# server:
|
||||
# ipv4_address: ${GRAFANA_NETWORK_ADDRESS:-172.28.0.11}
|
||||
|
||||
# node-exporter:
|
||||
# image: quay.io/prometheus/node-exporter
|
||||
# container_name: node-exporter
|
||||
# hostname: node-exporter
|
||||
# restart: always
|
||||
# ports:
|
||||
# - "${NODE_EXPORTER_PORT:-19100}:9100"
|
||||
# networks:
|
||||
# server:
|
||||
# ipv4_address: ${NODE_EXPORTER_NETWORK_ADDRESS:-172.28.0.12}
|
||||
|
||||
6
go.mod
6
go.mod
@ -1,6 +1,6 @@
|
||||
module github.com/openimsdk/open-im-server/v3
|
||||
|
||||
go 1.20
|
||||
go 1.21.2
|
||||
|
||||
require (
|
||||
firebase.google.com/go v3.13.0+incompatible
|
||||
@ -15,7 +15,7 @@ require (
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
github.com/openimsdk/localcache v0.0.1
|
||||
github.com/openimsdk/protocol v0.0.63
|
||||
github.com/openimsdk/tools v0.0.47-alpha.40
|
||||
github.com/openimsdk/tools v0.0.47-alpha.42
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/prometheus/client_golang v1.18.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
@ -34,7 +34,6 @@ require (
|
||||
github.com/go-redis/redis v6.15.9+incompatible
|
||||
github.com/kelindar/bitmap v1.5.2
|
||||
github.com/likexian/gokit v0.25.13
|
||||
github.com/magefile/mage v1.15.0
|
||||
github.com/openimsdk/gomake v0.0.6
|
||||
github.com/redis/go-redis/v9 v9.4.0
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
@ -101,6 +100,7 @@ require (
|
||||
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/lithammer/shortuuid v3.0.0+incompatible // indirect
|
||||
github.com/magefile/mage v1.15.0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
|
||||
|
||||
23
go.sum
23
go.sum
@ -22,10 +22,13 @@ github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mo
|
||||
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible h1:8psS8a+wKfiLt1iVDX79F7Y6wUM49Lcha2FMXt4UM8g=
|
||||
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
|
||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
|
||||
github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
|
||||
github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
|
||||
@ -43,6 +46,7 @@ github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5P
|
||||
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/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/PB79y4KOPYVyFYdROxgaCwdTQ=
|
||||
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa/go.mod h1:x/1Gn8zydmfq8dk6e9PdstVsDgu9RuyIIJqAaF//0IM=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@ -66,12 +70,15 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A=
|
||||
github.com/envoyproxy/protoc-gen-validate v1.0.4/go.mod h1:qys6tmnRsYrQqIhm2bvKZH4Blx/1gTIZ2UKVY1M+Yew=
|
||||
github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=
|
||||
github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
|
||||
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
@ -90,6 +97,7 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre
|
||||
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
@ -137,11 +145,13 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw=
|
||||
github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk=
|
||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o=
|
||||
github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw=
|
||||
@ -194,6 +204,7 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4=
|
||||
github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/kelindar/bitmap v1.5.2 h1:XwX7CTvJtetQZ64zrOkApoZZHBJRkjE23NfqUALA/HE=
|
||||
@ -209,7 +220,9 @@ github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02
|
||||
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
|
||||
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8=
|
||||
@ -270,8 +283,8 @@ github.com/openimsdk/gomake v0.0.6 h1:bJmQWDHBj8PQ7oGJ2SL3Gsx0k5CdI/BPfGzlGcV105
|
||||
github.com/openimsdk/gomake v0.0.6/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
|
||||
github.com/openimsdk/protocol v0.0.63 h1:9DnweZe9nEYDFa4fGTbC9Cqi0gLUdtBhRo1NRP2X3WQ=
|
||||
github.com/openimsdk/protocol v0.0.63/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
|
||||
github.com/openimsdk/tools v0.0.47-alpha.40 h1:Jhajwo7SpAGjAwp4c8sV+TPt0tzZP10MNGwgBDtMPNE=
|
||||
github.com/openimsdk/tools v0.0.47-alpha.40/go.mod h1:P4oGP1Pd+d4ctbLD5U/XQTgl8yu8Hd3skx640Fr69ko=
|
||||
github.com/openimsdk/tools v0.0.47-alpha.42 h1:wM6t9otTLhXECq8aQcYaZGvBgo/ZAmbNTqVt3g3NHGg=
|
||||
github.com/openimsdk/tools v0.0.47-alpha.42/go.mod h1:P4oGP1Pd+d4ctbLD5U/XQTgl8yu8Hd3skx640Fr69ko=
|
||||
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
|
||||
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
|
||||
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
|
||||
@ -282,6 +295,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
||||
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
|
||||
github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
|
||||
github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
@ -298,6 +312,7 @@ github.com/redis/go-redis/v9 v9.4.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
|
||||
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
||||
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
@ -376,6 +391,7 @@ go.opentelemetry.io/otel v1.23.0/go.mod h1:YCycw9ZeKhcJFrb34iVSkyT0iczq/zYDtZYFu
|
||||
go.opentelemetry.io/otel/metric v1.23.0 h1:pazkx7ss4LFVVYSxYew7L5I6qvLXHA0Ap2pwV+9Cnpo=
|
||||
go.opentelemetry.io/otel/metric v1.23.0/go.mod h1:MqUW2X2a6Q8RN96E2/nqNoT+z9BSms20Jb7Bbp+HiTo=
|
||||
go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8=
|
||||
go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E=
|
||||
go.opentelemetry.io/otel/trace v1.23.0 h1:37Ik5Ib7xfYVb4V1UtnT97T1jI+AoIYkJyPkuL4iJgI=
|
||||
go.opentelemetry.io/otel/trace v1.23.0/go.mod h1:GSGTbIClEsuZrGIzoEHqsVfxgn5UkggkflQwDScNUsk=
|
||||
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
|
||||
@ -383,6 +399,7 @@ go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8=
|
||||
go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
|
||||
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
|
||||
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
|
||||
@ -489,6 +506,7 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
|
||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
|
||||
google.golang.org/api v0.165.0 h1:zd5d4JIIIaYYsfVy1HzoXYZ9rWCSBxxAglbczzo7Bgc=
|
||||
google.golang.org/api v0.165.0/go.mod h1:2OatzO7ZDQsoS7IFf3rvsE17/TldiU3F/zxFHeqUB5o=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
@ -526,6 +544,7 @@ google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGm
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
|
||||
@ -20,10 +20,10 @@ import (
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/callbackstruct"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/util/memAsyncQueue"
|
||||
"github.com/openimsdk/protocol/constant"
|
||||
"github.com/openimsdk/tools/log"
|
||||
"github.com/openimsdk/tools/mcontext"
|
||||
"github.com/openimsdk/tools/mq/memamq"
|
||||
"github.com/openimsdk/tools/utils/httputil"
|
||||
"net/http"
|
||||
)
|
||||
@ -31,7 +31,7 @@ import (
|
||||
type Client struct {
|
||||
client *httputil.HTTPClient
|
||||
url string
|
||||
queue *memAsyncQueue.MemoryQueue
|
||||
queue *memamq.MemoryQueue
|
||||
}
|
||||
|
||||
const (
|
||||
@ -39,12 +39,12 @@ const (
|
||||
webhookBufferSize = 100
|
||||
)
|
||||
|
||||
func NewWebhookClient(url string, options ...*memAsyncQueue.MemoryQueue) *Client {
|
||||
var queue *memAsyncQueue.MemoryQueue
|
||||
func NewWebhookClient(url string, options ...*memamq.MemoryQueue) *Client {
|
||||
var queue *memamq.MemoryQueue
|
||||
if len(options) > 0 && options[0] != nil {
|
||||
queue = options[0]
|
||||
} else {
|
||||
queue = memAsyncQueue.NewMemoryQueue(webhookWorkerCount, webhookBufferSize)
|
||||
queue = memamq.NewMemoryQueue(webhookWorkerCount, webhookBufferSize)
|
||||
}
|
||||
|
||||
http.DefaultTransport.(*http.Transport).MaxConnsPerHost = 100 // Enhance the default number of max connections per host
|
||||
|
||||
@ -18,13 +18,13 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/util/memAsyncQueue"
|
||||
"github.com/openimsdk/protocol/constant"
|
||||
"github.com/openimsdk/protocol/msg"
|
||||
"github.com/openimsdk/protocol/sdkws"
|
||||
"github.com/openimsdk/tools/discovery"
|
||||
"github.com/openimsdk/tools/log"
|
||||
"github.com/openimsdk/tools/mcontext"
|
||||
"github.com/openimsdk/tools/mq/memamq"
|
||||
"github.com/openimsdk/tools/system/program"
|
||||
"github.com/openimsdk/tools/utils/idutil"
|
||||
"github.com/openimsdk/tools/utils/jsonutil"
|
||||
@ -217,10 +217,10 @@ type NotificationSender struct {
|
||||
sessionTypeConf map[int32]int32
|
||||
sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error)
|
||||
getUserInfo func(ctx context.Context, userID string) (*sdkws.UserInfo, error)
|
||||
queue *memAsyncQueue.MemoryQueue
|
||||
queue *memamq.MemoryQueue
|
||||
}
|
||||
|
||||
func WithQueue(queue *memAsyncQueue.MemoryQueue) NotificationSenderOptions {
|
||||
func WithQueue(queue *memamq.MemoryQueue) NotificationSenderOptions {
|
||||
return func(s *NotificationSender) {
|
||||
s.queue = queue
|
||||
}
|
||||
@ -257,7 +257,7 @@ func NewNotificationSender(conf *config.Notification, opts ...NotificationSender
|
||||
opt(notificationSender)
|
||||
}
|
||||
if notificationSender.queue == nil {
|
||||
notificationSender.queue = memAsyncQueue.NewMemoryQueue(notificationWorkerCount, notificationBufferSize)
|
||||
notificationSender.queue = memamq.NewMemoryQueue(notificationWorkerCount, notificationBufferSize)
|
||||
}
|
||||
return notificationSender
|
||||
}
|
||||
|
||||
@ -1,117 +0,0 @@
|
||||
package mageutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// StopBinaries iterates over all binary files and terminates their corresponding processes.
|
||||
func StopBinaries() {
|
||||
for binary := range serviceBinaries {
|
||||
fullPath := GetBinFullPath(binary)
|
||||
KillExistBinary(fullPath)
|
||||
}
|
||||
}
|
||||
|
||||
// StartBinaries Start all binary services.
|
||||
func StartBinaries() error {
|
||||
for binary, count := range serviceBinaries {
|
||||
binFullPath := filepath.Join(OpenIMOutputHostBin, binary)
|
||||
for i := 0; i < count; i++ {
|
||||
args := []string{"-i", strconv.Itoa(i), "-c", OpenIMOutputConfig}
|
||||
cmd := exec.Command(binFullPath, args...)
|
||||
fmt.Printf("Starting %s\n", cmd.String())
|
||||
cmd.Dir = OpenIMOutputHostBin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Start(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to start %s with args %v: %v\n", binFullPath, args, err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// StartTools starts all tool binaries.
|
||||
func StartTools() error {
|
||||
for _, tool := range toolBinaries {
|
||||
toolFullPath := GetToolFullPath(tool)
|
||||
cmd := exec.Command(toolFullPath, "-c", OpenIMOutputConfig)
|
||||
fmt.Printf("Starting %s\n", cmd.String())
|
||||
cmd.Dir = OpenIMOutputHostBinTools
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
if err := cmd.Start(); err != nil {
|
||||
fmt.Printf("Failed to start %s with error: %v\n", toolFullPath, err)
|
||||
return err
|
||||
}
|
||||
|
||||
if err := cmd.Wait(); err != nil {
|
||||
fmt.Printf("Failed to execute %s with exit code: %v\n", toolFullPath, err)
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Starting %s successfully \n", cmd.String())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// KillExistBinaries iterates over all binary files and kills their corresponding processes.
|
||||
func KillExistBinaries() {
|
||||
for binary := range serviceBinaries {
|
||||
fullPath := GetBinFullPath(binary)
|
||||
KillExistBinary(fullPath)
|
||||
}
|
||||
}
|
||||
|
||||
// CheckBinariesStop checks if all binary files have stopped and returns an error if there are any binaries still running.
|
||||
func CheckBinariesStop() error {
|
||||
var runningBinaries []string
|
||||
|
||||
for binary := range serviceBinaries {
|
||||
fullPath := GetBinFullPath(binary)
|
||||
if CheckProcessNamesExist(fullPath) {
|
||||
runningBinaries = append(runningBinaries, binary)
|
||||
}
|
||||
}
|
||||
|
||||
if len(runningBinaries) > 0 {
|
||||
return fmt.Errorf("the following binaries are still running: %s", strings.Join(runningBinaries, ", "))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckBinariesRunning checks if all binary files are running as expected and returns any errors encountered.
|
||||
func CheckBinariesRunning() error {
|
||||
var errorMessages []string
|
||||
|
||||
for binary, expectedCount := range serviceBinaries {
|
||||
fullPath := GetBinFullPath(binary)
|
||||
err := CheckProcessNames(fullPath, expectedCount)
|
||||
if err != nil {
|
||||
errorMessages = append(errorMessages, fmt.Sprintf("binary %s is not running as expected: %v", binary, err))
|
||||
}
|
||||
}
|
||||
|
||||
if len(errorMessages) > 0 {
|
||||
return fmt.Errorf(strings.Join(errorMessages, "\n"))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// PrintListenedPortsByBinaries iterates over all binary files and prints the ports they are listening on.
|
||||
func PrintListenedPortsByBinaries() {
|
||||
for binary, _ := range serviceBinaries {
|
||||
basePath := GetBinFullPath(binary)
|
||||
fullPath := basePath
|
||||
PrintBinaryPorts(fullPath)
|
||||
}
|
||||
}
|
||||
@ -1,235 +0,0 @@
|
||||
package mageutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/magefile/mage/sh"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// CheckAndReportBinariesStatus checks the running status of all binary files and reports it.
|
||||
func CheckAndReportBinariesStatus() {
|
||||
InitForSSC()
|
||||
err := CheckBinariesRunning()
|
||||
if err != nil {
|
||||
PrintRed("Some programs are not running properly:")
|
||||
PrintRedNoTimeStamp(err.Error())
|
||||
return
|
||||
}
|
||||
PrintGreen("All services are running normally.")
|
||||
PrintBlue("Display details of the ports listened to by the service:")
|
||||
PrintListenedPortsByBinaries()
|
||||
}
|
||||
|
||||
// StopAndCheckBinaries stops all binary processes and checks if they have all stopped.
|
||||
func StopAndCheckBinaries() {
|
||||
InitForSSC()
|
||||
KillExistBinaries()
|
||||
err := CheckBinariesStop()
|
||||
if err != nil {
|
||||
PrintRed("Some services have not been stopped, details are as follows:" + err.Error())
|
||||
return
|
||||
}
|
||||
PrintGreen("All services have been stopped")
|
||||
}
|
||||
|
||||
// StartToolsAndServices starts the process for tools and services.
|
||||
func StartToolsAndServices() {
|
||||
InitForSSC()
|
||||
PrintBlue("Starting tools primarily involves component verification and other preparatory tasks.")
|
||||
if err := StartTools(); err != nil {
|
||||
PrintRed("Some tools failed to start, details are as follows, abort start")
|
||||
PrintRedNoTimeStamp(err.Error())
|
||||
return
|
||||
}
|
||||
PrintGreen("All tools executed successfully")
|
||||
|
||||
KillExistBinaries()
|
||||
err := CheckBinariesStop()
|
||||
if err != nil {
|
||||
PrintRed("Some services running, details are as follows, abort start " + err.Error())
|
||||
return
|
||||
}
|
||||
PrintBlue("Starting services involves multiple RPCs and APIs and may take some time. Please be patient")
|
||||
err = StartBinaries()
|
||||
if err != nil {
|
||||
PrintRed("Failed to start all binaries")
|
||||
PrintRedNoTimeStamp(err.Error())
|
||||
return
|
||||
}
|
||||
CheckAndReportBinariesStatus()
|
||||
}
|
||||
|
||||
// CompileForPlatform Main compile function
|
||||
func CompileForPlatform(platform string) {
|
||||
|
||||
PrintBlue(fmt.Sprintf("Compiling cmd for %s...", platform))
|
||||
|
||||
cmdCompiledDirs := compileDir(filepath.Join(rootDirPath, "cmd"), platformsOutputBase, platform)
|
||||
|
||||
PrintBlue(fmt.Sprintf("Compiling tools for %s...", platform))
|
||||
toolsCompiledDirs := compileDir(filepath.Join(rootDirPath, "tools"), toolsOutputBase, platform)
|
||||
createStartConfigYML(cmdCompiledDirs, toolsCompiledDirs)
|
||||
|
||||
}
|
||||
|
||||
func createStartConfigYML(cmdDirs, toolsDirs []string) {
|
||||
configPath := filepath.Join(rootDirPath, "start-config.yml")
|
||||
|
||||
if _, err := os.Stat(configPath); !os.IsNotExist(err) {
|
||||
PrintBlue("start-config.yml already exists, skipping creation.")
|
||||
return
|
||||
}
|
||||
|
||||
var content strings.Builder
|
||||
content.WriteString("serviceBinaries:\n")
|
||||
for _, dir := range cmdDirs {
|
||||
content.WriteString(fmt.Sprintf(" %s: 1\n", dir))
|
||||
}
|
||||
content.WriteString("toolBinaries:\n")
|
||||
for _, dir := range toolsDirs {
|
||||
content.WriteString(fmt.Sprintf(" - %s\n", dir))
|
||||
}
|
||||
content.WriteString("maxFileDescriptors: 10000\n")
|
||||
|
||||
err := ioutil.WriteFile(configPath, []byte(content.String()), 0644)
|
||||
if err != nil {
|
||||
PrintRed("Failed to create start-config.yml: " + err.Error())
|
||||
return
|
||||
}
|
||||
PrintGreen("start-config.yml created successfully.")
|
||||
}
|
||||
|
||||
func compileDir(sourceDir, outputBase, platform string) []string {
|
||||
var compiledDirs []string
|
||||
var mu sync.Mutex
|
||||
targetOS, targetArch := strings.Split(platform, "_")[0], strings.Split(platform, "_")[1]
|
||||
outputDir := filepath.Join(outputBase, targetOS, targetArch)
|
||||
|
||||
if err := os.MkdirAll(outputDir, 0755); err != nil {
|
||||
fmt.Printf("Failed to create directory %s: %v\n", outputDir, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
errors := make(chan error, 1)
|
||||
sem := make(chan struct{}, 4)
|
||||
|
||||
err := filepath.Walk(sourceDir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if info.IsDir() || filepath.Base(path) != "main.go" {
|
||||
return nil
|
||||
}
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
sem <- struct{}{}
|
||||
defer wg.Done()
|
||||
defer func() { <-sem }()
|
||||
|
||||
dir := filepath.Dir(path)
|
||||
dirName := filepath.Base(dir)
|
||||
outputFileName := dirName
|
||||
if targetOS == "windows" {
|
||||
outputFileName += ".exe"
|
||||
}
|
||||
|
||||
PrintBlue(fmt.Sprintf("Compiling dir: %s for platform: %s binary: %s ...", dirName, platform, outputFileName))
|
||||
err := sh.RunWith(map[string]string{"GOOS": targetOS, "GOARCH": targetArch}, "go", "build", "-o", filepath.Join(outputDir, outputFileName), filepath.Join(dir, "main.go"))
|
||||
if err != nil {
|
||||
errors <- fmt.Errorf("failed to compile %s for %s: %v", dirName, platform, err)
|
||||
PrintRed("Compilation aborted. " + fmt.Sprintf("failed to compile %s for %s: %v", dirName, platform, err))
|
||||
os.Exit(1)
|
||||
return
|
||||
}
|
||||
PrintGreen(fmt.Sprintf("Successfully compiled. dir: %s for platform: %s binary: %s", dirName, platform, outputFileName))
|
||||
mu.Lock()
|
||||
compiledDirs = append(compiledDirs, dirName)
|
||||
mu.Unlock()
|
||||
}()
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Error walking through directories:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
close(errors)
|
||||
|
||||
// Check for errors
|
||||
if err, ok := <-errors; ok {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
return compiledDirs
|
||||
}
|
||||
|
||||
// compileDir compiles Go programs in a specified directory, appending .exe extension for output files on Windows platform
|
||||
//func compileDir(sourceDir, outputBase, platform string) {
|
||||
// targetOS, targetArch := strings.Split(platform, "_")[0], strings.Split(platform, "_")[1]
|
||||
// outputDir := filepath.Join(outputBase, targetOS, targetArch)
|
||||
//
|
||||
// if err := os.MkdirAll(outputDir, 0755); err != nil {
|
||||
// fmt.Printf("Failed to create directory %s: %v\n", outputDir, err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
//
|
||||
// var wg sync.WaitGroup
|
||||
// errors := make(chan error, 1)
|
||||
//
|
||||
// err := filepath.Walk(sourceDir, func(path string, info os.FileInfo, err error) error {
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// if info.IsDir() || filepath.Base(path) != "main.go" {
|
||||
// return nil
|
||||
// }
|
||||
//
|
||||
// wg.Add(1)
|
||||
// go func() {
|
||||
// defer wg.Done()
|
||||
//
|
||||
// dir := filepath.Dir(path)
|
||||
// dirName := filepath.Base(dir)
|
||||
// outputFileName := dirName
|
||||
// if targetOS == "windows" {
|
||||
// outputFileName += ".exe"
|
||||
// }
|
||||
//
|
||||
// PrintBlue(fmt.Sprintf("Compiling dir: %s for platform: %s binary: %s ...", dirName, platform, outputFileName))
|
||||
// err := sh.RunWith(map[string]string{"GOOS": targetOS, "GOARCH": targetArch}, "go", "build", "-o", filepath.Join(outputDir, outputFileName), filepath.Join(dir, "main.go"))
|
||||
// if err != nil {
|
||||
// errors <- fmt.Errorf("failed to compile %s for %s: %v", dirName, platform, err)
|
||||
// PrintRed("Compilation aborted. " + fmt.Sprintf("failed to compile %s for %s: %v", dirName, platform, err))
|
||||
// os.Exit(1)
|
||||
// return
|
||||
// }
|
||||
// PrintGreen(fmt.Sprintf("Compiling dir: %s for platform: %s binary: %s ...", dirName, platform, outputFileName))
|
||||
// }()
|
||||
//
|
||||
// return nil
|
||||
// })
|
||||
//
|
||||
// if err != nil {
|
||||
// fmt.Println("Error walking through directories:", err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
//
|
||||
// wg.Wait()
|
||||
// close(errors)
|
||||
//
|
||||
// // Check for errors
|
||||
// if err, ok := <-errors; ok {
|
||||
// fmt.Println(err)
|
||||
// fmt.Println("Compilation aborted.")
|
||||
// os.Exit(1)
|
||||
// }
|
||||
//}
|
||||
@ -1,45 +0,0 @@
|
||||
package mageutil
|
||||
|
||||
import (
|
||||
"gopkg.in/yaml.v3"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var (
|
||||
serviceBinaries map[string]int
|
||||
toolBinaries []string
|
||||
MaxFileDescriptors int
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
ServiceBinaries map[string]int `yaml:"serviceBinaries"`
|
||||
ToolBinaries []string `yaml:"toolBinaries"`
|
||||
MaxFileDescriptors int `yaml:"maxFileDescriptors"`
|
||||
}
|
||||
|
||||
func InitForSSC() {
|
||||
yamlFile, err := ioutil.ReadFile("start-config.yml")
|
||||
if err != nil {
|
||||
log.Fatalf("error reading YAML file: %v", err)
|
||||
}
|
||||
|
||||
var config Config
|
||||
err = yaml.Unmarshal(yamlFile, &config)
|
||||
if err != nil {
|
||||
log.Fatalf("error unmarshalling YAML: %v", err)
|
||||
}
|
||||
|
||||
adjustedBinaries := make(map[string]int)
|
||||
for binary, count := range config.ServiceBinaries {
|
||||
if runtime.GOOS == "windows" {
|
||||
binary += ".exe"
|
||||
}
|
||||
adjustedBinaries[binary] = count
|
||||
}
|
||||
|
||||
serviceBinaries = adjustedBinaries
|
||||
toolBinaries = config.ToolBinaries
|
||||
MaxFileDescriptors = config.MaxFileDescriptors
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
package mageutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
ColorBlue = "\033[0;34m"
|
||||
ColorGreen = "\033[0;32m"
|
||||
ColorRed = "\033[0;31m"
|
||||
ColorReset = "\033[0m"
|
||||
)
|
||||
|
||||
func PrintBlueTwoLine(message string) {
|
||||
currentTime := time.Now().Format("[2006-01-02 15:04:05 MST]")
|
||||
fmt.Println(currentTime)
|
||||
fmt.Printf("%s%s%s\n", ColorBlue, message, ColorReset)
|
||||
}
|
||||
|
||||
func PrintBlue(message string) {
|
||||
currentTime := time.Now().Format("[2006-01-02 15:04:05 MST]")
|
||||
fmt.Printf("%s %s%s%s\n", currentTime, ColorBlue, message, ColorReset)
|
||||
}
|
||||
|
||||
func PrintGreenTwoLine(message string) {
|
||||
currentTime := time.Now().Format("[2006-01-02 15:04:05 MST]")
|
||||
fmt.Println(currentTime)
|
||||
fmt.Printf("%s%s%s\n", ColorGreen, message, ColorReset)
|
||||
}
|
||||
|
||||
func PrintGreen(message string) {
|
||||
currentTime := time.Now().Format("[2006-01-02 15:04:05 MST]")
|
||||
fmt.Printf("%s %s%s%s\n", currentTime, ColorGreen, message, ColorReset)
|
||||
}
|
||||
|
||||
func PrintRed(message string) {
|
||||
currentTime := time.Now().Format("[2006-01-02 15:04:05 MST]")
|
||||
fmt.Printf("%s %s%s%s\n", currentTime, ColorRed, message, ColorReset)
|
||||
}
|
||||
|
||||
func PrintRedNoTimeStamp(message string) {
|
||||
fmt.Printf("%s%s%s\n", ColorRed, message, ColorReset)
|
||||
}
|
||||
|
||||
func PrintGreenNoTimeStamp(message string) {
|
||||
fmt.Printf("%s%s%s\n", ColorGreen, message, ColorReset)
|
||||
}
|
||||
|
||||
func PrintRedToStdErr(a ...interface{}) (n int, err error) {
|
||||
return fmt.Fprint(os.Stderr, "\033[31m", fmt.Sprint(a...), "\033[0m")
|
||||
}
|
||||
func PrintGreenToStdOut(a ...interface{}) (n int, err error) {
|
||||
return fmt.Fprint(os.Stdout, "\033[32m", fmt.Sprint(a...), "\033[0m")
|
||||
}
|
||||
@ -1,85 +0,0 @@
|
||||
package mageutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var (
|
||||
OpenIMRoot string
|
||||
OpenIMOutputConfig string
|
||||
OpenIMOutput string
|
||||
OpenIMOutputTools string
|
||||
OpenIMOutputTmp string
|
||||
OpenIMOutputLogs string
|
||||
OpenIMOutputBin string
|
||||
OpenIMOutputBinPath string
|
||||
OpenIMOutputBinToolPath string
|
||||
OpenIMInitErrLogFile string
|
||||
OpenIMInitLogFile string
|
||||
OpenIMOutputHostBin string
|
||||
OpenIMOutputHostBinTools string
|
||||
)
|
||||
|
||||
func init() {
|
||||
currentDir, err := os.Getwd()
|
||||
if err != nil {
|
||||
panic("Error getting current directory: " + err.Error())
|
||||
}
|
||||
|
||||
OpenIMRoot = currentDir
|
||||
|
||||
OpenIMOutputConfig = filepath.Join(OpenIMRoot, "config") + string(filepath.Separator)
|
||||
OpenIMOutput = filepath.Join(OpenIMRoot, "_output") + string(filepath.Separator)
|
||||
|
||||
OpenIMOutputTools = filepath.Join(OpenIMOutput, "tools") + string(filepath.Separator)
|
||||
OpenIMOutputTmp = filepath.Join(OpenIMOutput, "tmp") + string(filepath.Separator)
|
||||
OpenIMOutputLogs = filepath.Join(OpenIMOutput, "logs") + string(filepath.Separator)
|
||||
OpenIMOutputBin = filepath.Join(OpenIMOutput, "bin") + string(filepath.Separator)
|
||||
|
||||
OpenIMOutputBinPath = filepath.Join(OpenIMOutputBin, "platforms") + string(filepath.Separator)
|
||||
OpenIMOutputBinToolPath = filepath.Join(OpenIMOutputBin, "tools") + string(filepath.Separator)
|
||||
|
||||
OpenIMInitErrLogFile = filepath.Join(OpenIMOutputLogs, "openim-init-err.log")
|
||||
OpenIMInitLogFile = filepath.Join(OpenIMOutputLogs, "openim-init.log")
|
||||
|
||||
OpenIMOutputHostBin = filepath.Join(OpenIMOutputBinPath, OsArch()) + string(filepath.Separator)
|
||||
OpenIMOutputHostBinTools = filepath.Join(OpenIMOutputBinToolPath, OsArch()) + string(filepath.Separator)
|
||||
|
||||
dirs := []string{
|
||||
OpenIMOutputConfig,
|
||||
OpenIMOutput,
|
||||
OpenIMOutputTools,
|
||||
OpenIMOutputTmp,
|
||||
OpenIMOutputLogs,
|
||||
OpenIMOutputBin,
|
||||
OpenIMOutputBinPath,
|
||||
OpenIMOutputBinToolPath,
|
||||
OpenIMOutputHostBin,
|
||||
OpenIMOutputHostBinTools,
|
||||
}
|
||||
|
||||
for _, dir := range dirs {
|
||||
createDirIfNotExist(dir)
|
||||
}
|
||||
}
|
||||
|
||||
func createDirIfNotExist(dir string) {
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
fmt.Printf("Failed to create directory %s: %v\n", dir, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// GetBinFullPath constructs and returns the full path for the given binary name.
|
||||
func GetBinFullPath(binName string) string {
|
||||
binFullPath := filepath.Join(OpenIMOutputHostBin, binName)
|
||||
return binFullPath
|
||||
}
|
||||
|
||||
// GetToolFullPath constructs and returns the full path for the given tool name.
|
||||
func GetToolFullPath(toolName string) string {
|
||||
toolFullPath := filepath.Join(OpenIMOutputHostBinTools, toolName)
|
||||
return toolFullPath
|
||||
}
|
||||
@ -1,208 +0,0 @@
|
||||
package mageutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/shirou/gopsutil/net"
|
||||
"github.com/shirou/gopsutil/process"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func OsArch() string {
|
||||
os := runtime.GOOS
|
||||
arch := runtime.GOARCH
|
||||
if os == "windows" {
|
||||
return fmt.Sprintf("%s\\%s", os, arch)
|
||||
}
|
||||
return fmt.Sprintf("%s/%s", os, arch)
|
||||
}
|
||||
|
||||
func CheckProcessNames(processPath string, expectedCount int) error {
|
||||
processes, err := process.Processes()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get processes: %v", err)
|
||||
}
|
||||
|
||||
runningCount := 0
|
||||
for _, p := range processes {
|
||||
exePath, err := p.Exe()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.EqualFold(exePath, processPath) {
|
||||
runningCount++
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if runningCount == expectedCount {
|
||||
return nil
|
||||
} else {
|
||||
return fmt.Errorf("%s Expected %d processes, but %d running", processPath, expectedCount, runningCount)
|
||||
}
|
||||
}
|
||||
|
||||
// CheckProcessNamesExist checks if there are any processes running that match the specified path.
|
||||
func CheckProcessNamesExist(processPath string) bool {
|
||||
processes, err := process.Processes()
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to get processes: %v\n", err)
|
||||
return false
|
||||
}
|
||||
|
||||
for _, p := range processes {
|
||||
exePath, err := p.Exe()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if exePath == processPath {
|
||||
return true // 找到至少一个匹配的进程
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// PrintBinaryPorts prints the ports listened by the process of a specified binary file along with its command line arguments.
|
||||
func PrintBinaryPorts(binaryPath string) {
|
||||
pids, err := FindPIDsByBinaryPath(binaryPath)
|
||||
if err != nil {
|
||||
fmt.Println("Error finding PIDs:", err)
|
||||
return
|
||||
}
|
||||
|
||||
if len(pids) == 0 {
|
||||
fmt.Printf("No running processes found for binary: %s\n", binaryPath)
|
||||
return
|
||||
}
|
||||
|
||||
for _, pid := range pids {
|
||||
|
||||
proc, err := process.NewProcess(int32(pid))
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to create process object for PID %d: %v\n", pid, err)
|
||||
continue
|
||||
}
|
||||
|
||||
cmdline, err := proc.Cmdline()
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to get command line for PID %d: %v\n", pid, err)
|
||||
continue
|
||||
}
|
||||
|
||||
connections, err := net.ConnectionsPid("all", int32(pid))
|
||||
if err != nil {
|
||||
fmt.Printf("Error getting connections for PID %d: %v\n", pid, err)
|
||||
continue
|
||||
}
|
||||
|
||||
portsMap := make(map[string]struct{})
|
||||
for _, conn := range connections {
|
||||
if conn.Status == "LISTEN" {
|
||||
port := fmt.Sprintf("%d", conn.Laddr.Port)
|
||||
portsMap[port] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
if len(portsMap) == 0 {
|
||||
PrintGreen(fmt.Sprintf("Cmdline: %s, PID: %d is not listening on any ports.", cmdline, pid))
|
||||
} else {
|
||||
ports := make([]string, 0, len(portsMap))
|
||||
for port := range portsMap {
|
||||
ports = append(ports, port)
|
||||
}
|
||||
PrintGreen(fmt.Sprintf("Cmdline: %s, PID: %d is listening on ports: %s", cmdline, pid, strings.Join(ports, ", ")))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FindPIDsByBinaryPath finds all matching process PIDs by binary path.
|
||||
func FindPIDsByBinaryPath(binaryPath string) ([]int, error) {
|
||||
var pids []int
|
||||
processes, err := process.Processes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, proc := range processes {
|
||||
exePath, err := proc.Exe()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.EqualFold(exePath, binaryPath) {
|
||||
pids = append(pids, int(proc.Pid))
|
||||
}
|
||||
}
|
||||
|
||||
return pids, nil
|
||||
}
|
||||
|
||||
// KillExistBinary kills all processes matching the given binary file path.
|
||||
func KillExistBinary(binaryPath string) {
|
||||
processes, err := process.Processes()
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to get processes: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, p := range processes {
|
||||
exePath, err := p.Exe()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.Contains(strings.ToLower(exePath), strings.ToLower(binaryPath)) {
|
||||
|
||||
//if strings.EqualFold(exePath, binaryPath) {
|
||||
cmdline, err := p.Cmdline()
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to get command line for process %d: %v\n", p.Pid, err)
|
||||
continue
|
||||
}
|
||||
|
||||
err = p.Terminate()
|
||||
if err != nil {
|
||||
|
||||
err = p.Kill()
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to kill process cmdline: %s, pid: %d, err: %v\n", cmdline, p.Pid, err)
|
||||
} else {
|
||||
fmt.Printf("Killed process cmdline: %s, pid: %d\n", cmdline, p.Pid)
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("Terminated process cmdline: %s, pid: %d\n", cmdline, p.Pid)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DetectPlatform detects the operating system and architecture.
|
||||
func DetectPlatform() string {
|
||||
targetOS, targetArch := runtime.GOOS, runtime.GOARCH
|
||||
switch targetArch {
|
||||
case "amd64", "arm64":
|
||||
default:
|
||||
fmt.Printf("Unsupported architecture: %s\n", targetArch)
|
||||
os.Exit(1)
|
||||
}
|
||||
return fmt.Sprintf("%s_%s", targetOS, targetArch)
|
||||
}
|
||||
|
||||
// rootDir gets the absolute path of the current directory.
|
||||
func rootDir() string {
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
fmt.Println("Failed to get current directory:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
return dir
|
||||
}
|
||||
|
||||
var rootDirPath = rootDir()
|
||||
var platformsOutputBase = filepath.Join(rootDirPath, "_output/bin/platforms")
|
||||
var toolsOutputBase = filepath.Join(rootDirPath, "_output/bin/tools")
|
||||
@ -1,72 +0,0 @@
|
||||
package memAsyncQueue
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// AsyncQueue is the interface responsible for asynchronous processing of functions.
|
||||
type AsyncQueue interface {
|
||||
Initialize(processFunc func(), workerCount int, bufferSize int)
|
||||
Push(task func()) error
|
||||
}
|
||||
|
||||
// MemoryQueue is an implementation of the AsyncQueue interface using a channel to process functions.
|
||||
type MemoryQueue struct {
|
||||
taskChan chan func()
|
||||
wg sync.WaitGroup
|
||||
isStopped bool
|
||||
stopMutex sync.Mutex // Mutex to protect access to isStopped
|
||||
}
|
||||
|
||||
func NewMemoryQueue(workerCount int, bufferSize int) *MemoryQueue {
|
||||
mq := &MemoryQueue{} // Create a new instance of MemoryQueue
|
||||
mq.Initialize(workerCount, bufferSize) // Initialize it with specified parameters
|
||||
return mq
|
||||
}
|
||||
|
||||
// Initialize sets up the worker nodes and the buffer size of the channel,
|
||||
// starting internal goroutines to handle tasks from the channel.
|
||||
func (mq *MemoryQueue) Initialize(workerCount int, bufferSize int) {
|
||||
mq.taskChan = make(chan func(), bufferSize) // Initialize the channel with the provided buffer size.
|
||||
mq.isStopped = false
|
||||
|
||||
// Start multiple goroutines based on the specified workerCount.
|
||||
for i := 0; i < workerCount; i++ {
|
||||
mq.wg.Add(1)
|
||||
go func(workerID int) {
|
||||
defer mq.wg.Done()
|
||||
for task := range mq.taskChan {
|
||||
task() // Execute the function
|
||||
}
|
||||
}(i)
|
||||
}
|
||||
}
|
||||
|
||||
// Push submits a function to the queue.
|
||||
// Returns an error if the queue is stopped or if the queue is full.
|
||||
func (mq *MemoryQueue) Push(task func()) error {
|
||||
mq.stopMutex.Lock()
|
||||
if mq.isStopped {
|
||||
mq.stopMutex.Unlock()
|
||||
return errors.New("push failed: queue is stopped")
|
||||
}
|
||||
mq.stopMutex.Unlock()
|
||||
|
||||
select {
|
||||
case mq.taskChan <- task:
|
||||
return nil
|
||||
case <-time.After(time.Millisecond * 100): // Timeout to prevent deadlock/blocking
|
||||
return errors.New("push failed: queue is full")
|
||||
}
|
||||
}
|
||||
|
||||
// Stop is used to terminate the internal goroutines and close the channel.
|
||||
func (mq *MemoryQueue) Stop() {
|
||||
mq.stopMutex.Lock()
|
||||
mq.isStopped = true
|
||||
close(mq.taskChan)
|
||||
mq.stopMutex.Unlock()
|
||||
mq.wg.Wait()
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
package memAsyncQueue
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestNewMemoryQueue(t *testing.T) {
|
||||
workerCount := 3
|
||||
bufferSize := 10
|
||||
queue := NewMemoryQueue(workerCount, bufferSize)
|
||||
|
||||
if cap(queue.taskChan) != bufferSize {
|
||||
t.Errorf("Expected buffer size %d, got %d", bufferSize, cap(queue.taskChan))
|
||||
}
|
||||
|
||||
if queue.isStopped {
|
||||
t.Errorf("New queue is prematurely stopped")
|
||||
}
|
||||
|
||||
if len(queue.taskChan) != 0 {
|
||||
t.Errorf("New queue should be empty, found %d items", len(queue.taskChan))
|
||||
}
|
||||
}
|
||||
|
||||
func TestPushAndStop(t *testing.T) {
|
||||
queue := NewMemoryQueue(1, 5)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
queue.Push(func() {
|
||||
time.Sleep(50 * time.Millisecond) // Simulate task delay
|
||||
wg.Done()
|
||||
})
|
||||
|
||||
queue.Stop()
|
||||
wg.Wait()
|
||||
|
||||
if err := queue.Push(func() {}); err == nil {
|
||||
t.Error("Expected error when pushing to stopped queue, got none")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPushTimeout(t *testing.T) {
|
||||
queue := NewMemoryQueue(1, 1) // Small buffer and worker to force full queue
|
||||
|
||||
done := make(chan bool)
|
||||
go func() {
|
||||
queue.Push(func() {
|
||||
time.Sleep(200 * time.Millisecond) // Long enough to cause the second push to timeout
|
||||
})
|
||||
done <- true
|
||||
}()
|
||||
|
||||
<-done // Ensure first task is pushed
|
||||
|
||||
if err := queue.Push(func() {}); err != nil {
|
||||
t.Error("Expected timeout error, got nil")
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user