go-zero modd开发配置
go-zero modd开发配置
modd配置
modd.conf
#usercenter
app/usercenter/cmd/rpc/**/*.go {
prep: go build -o data/server/usercenter-rpc -v app/usercenter/cmd/rpc/usercenter.go
daemon +sigkill: ./data/server/usercenter-rpc -f app/usercenter/cmd/rpc/etc/usercenter.yaml
}
app/usercenter/cmd/api/**/*.go {
prep: go build -o data/server/usercenter-api -v app/usercenter/cmd/api/usercenter.go
daemon +sigkill: ./data/server/usercenter-api -f app/usercenter/cmd/api/etc/usercenter.yaml
}
#notice
#app/notice/cmd/api/**/*.go {
# prep: go build -o data/server/notice-api -v app/notice/cmd/api/notice.go
# daemon +sigkill: ./data/server/notice-api -f app/notice/cmd/api/etc/notice.yaml
#}
#upload
app/upload/cmd/rpc/**/*.go {
prep: go build -o data/server/upload-rpc -v app/upload/cmd/rpc/upload.go
daemon +sigkill: ./data/server/upload-rpc -f app/upload/cmd/rpc/etc/upload.yaml
}
app/upload/cmd/api/**/*.go {
prep: go build -o data/server/upload-api -v app/upload/cmd/api/upload.go
daemon +sigkill: ./data/server/upload-api -f app/upload/cmd/api/etc/upload.yaml
}
#travel
app/travel/cmd/rpc/**/*.go {
prep: go build -o data/server/travel-rpc -v app/travel/cmd/rpc/travel.go
daemon +sigkill: ./data/server/travel-rpc -f app/travel/cmd/rpc/etc/travel.yaml
}
app/travel/cmd/api/**/*.go {
prep: go build -o data/server/travel-api -v app/travel/cmd/api/travel.go
daemon +sigkill: ./data/server/travel-api -f app/travel/cmd/api/etc/travel.yaml
}
##payment
#app/payment/cmd/rpc/**/*.go {
# prep: go build -o data/server/payment-rpc -v app/payment/cmd/rpc/payment.go
# daemon +sigkill: ./data/server/payment-rpc -f app/payment/cmd/rpc/etc/payment.yaml
#}
#app/payment/cmd/api/**/*.go {
# prep: go build -o data/server/payment-api -v app/payment/cmd/api/payment.go
# daemon +sigkill: ./data/server/payment-api -f app/payment/cmd/api/etc/payment.yaml
#}
##order
#app/order/cmd/rpc/**/*.go {
# prep: go build -o data/server/order-rpc -v app/order/cmd/rpc/order.go
# daemon +sigkill: ./data/server/order-rpc -f app/order/cmd/rpc/etc/order.yaml
#}
#app/order/cmd/api/**/*.go {
# prep: go build -o data/server/order-api -v app/order/cmd/api/order.go
# daemon +sigkill: ./data/server/order-api -f app/order/cmd/api/etc/order.yaml
#}
#app/order/cmd/mq/**/*.go {
# prep: go build -o data/server/order-mq -v app/order/cmd/mq/order.go
# daemon +sigkill: ./data/server/order-mq -f app/order/cmd/mq/etc/order.yaml
#}
##mqueue
#app/mqueue/cmd/scheduler/**/*.go {
# prep: go build -o data/server/mqueue-scheduler -v app/mqueue/cmd/scheduler/mqueue.go
# daemon +sigkill: ./data/server/mqueue-scheduler -f app/mqueue/cmd/scheduler/etc/mqueue.yaml
#}
#app/mqueue/cmd/job/**/*.go {
# prep: go build -o data/server/mqueue-job -v app/mqueue/cmd/job/mqueue.go
# daemon +sigkill: ./data/server/mqueue-job -f app/mqueue/cmd/job/etc/mqueue.yaml
#}
项目打包编排文件
docker-compose.yml
version: '3'
######## app下api+rpc , Before starting this project, start the environment that the project depends on docker-compose-env.yml #######
services:
#前端网关nginx-gateay (只代理looklook,admin-api不在这里做代理)
# Front-end gateway nginx-gateway (Only agent looklook,admin-api Do not be an agent here)
nginx-gateway:
image: nginx:1.21.5
container_name: nginx-gateway
restart: always
privileged: true
environment:
- TZ=Asia/Shanghai
ports:
- 8888:8081
volumes:
- ./deploy/nginx/conf.d:/etc/nginx/conf.d
- ./data/nginx/log:/var/log/nginx
networks:
- looklook_net
depends_on:
- looklook
#前端api + 业务rpc - Front-end API + business RPC
looklook:
# docker-hub : https://hub.docker.com/r/lyumikael/gomodd
# dockerfile: https://github.com/Mikaelemmmm/gomodd , If you are macOs m1\m2 use dockerfile yourself to build the image
image: lyumikael/gomodd:v1.20.3
container_name: looklook
environment:
# 时区上海 - Timezone Shanghai
TZ: Asia/Shanghai
GOPROXY: https://goproxy.cn,direct
working_dir: /go/looklook
volumes:
- .:/go/looklook
privileged: true
restart: always
networks:
- looklook_net
networks:
looklook_net:
driver: bridge
external: true #着重看这里
ipam:
config:
- subnet: 172.20.0.0/16
nginx配置文件
deploy/nginx/conf.d/looklook-gateway.conf
server{
listen 8081;
access_log /var/log/nginx/looklook.com_access.log;
error_log /var/log/nginx/looklook.com_error.log;
location ~ /order/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://looklook:1001;
}
location ~ /payment/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://looklook:1002;
}
location ~ /travel/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://looklook:1003;
}
location ~ /usercenter/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://looklook:1004;
}
location ~ /lottery/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://looklook:1005;
}
location ~ /notice/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://looklook:1006;
}
location ~ /upload/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://looklook:1008;
}
}
deploy/prometheus/server/prometheus.yml
global:
scrape_interval:
external_labels:
monitor: 'codelab-monitor'
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 5s #global catch time
static_configs:
- targets: ['127.0.0.1:9090']
- job_name: 'order-api'
static_configs:
- targets: [ 'looklook:4001' ]
labels:
job: order-api
app: order-api
env: dev
- job_name: 'order-rpc'
static_configs:
- targets: [ 'looklook:4002' ]
labels:
job: order-rpc
app: order-rpc
env: dev
- job_name: 'order-mq'
static_configs:
- targets: [ 'looklook:4003' ]
labels:
job: order-mq
app: order-mq
env: dev
- job_name: 'payment-api'
static_configs:
- targets: [ 'looklook:4004' ]
labels:
job: payment-api
app: payment-api
env: dev
- job_name: 'payment-rpc'
static_configs:
- targets: [ 'looklook:4005' ]
labels:
job: payment-rpc
app: payment-rpc
env: dev
- job_name: 'travel-api'
static_configs:
- targets: [ 'looklook:4006' ]
labels:
job: travel-api
app: travel-api
env: dev
- job_name: 'travel-rpc'
static_configs:
- targets: [ 'looklook:4007' ]
labels:
job: travel-rpc
app: travel-rpc
env: dev
- job_name: 'usercenter-api'
static_configs:
- targets: ['looklook:4008']
labels:
job: usercenter-api
app: usercenter-api
env: dev
- job_name: 'usercenter-rpc'
static_configs:
- targets: ['looklook:4009']
labels:
job: usercenter-rpc
app: usercenter-rpc
env: dev
- job_name: 'mqueue-job'
static_configs:
- targets: [ 'looklook:4010' ]
labels:
job: mqueue-job
app: mqueue-job
env: dev
- job_name: 'mqueue-scheduler'
static_configs:
- targets: [ 'looklook:4011' ]
labels:
job: mqueue-scheduler
app: mqueue-scheduler
env: dev
- job_name: 'upload-api'
static_configs:
- targets: ['looklook:4012']
labels:
job: upload-api
app: upload-api
env: dev
- job_name: 'upload-rpc'
static_configs:
- targets: ['looklook:4013']
labels:
job: upload-rpc
app: upload-rpc
env: dev
各服务中的配置里要写上如下配置
用于给Prometheus提供监控服务
如:
app/upload/cmd/api/etc/upload.yaml
#监控
Prometheus:
Host: 0.0.0.0
Port: 4014
Path: /metrics
环境配置
docker-compose-env.yml
version: '3'
######## 项目依赖的环境,启动项目之前要先启动此环境 #######
######## The environment that the project depends on, starting this environment before starting the project #######
services:
#jaeger链路追踪 — Jaeger for tracing
jaeger:
image: jaegertracing/all-in-one:1.42.0
container_name: jaeger
restart: always
ports:
- "5775:5775/udp"
- "6831:6831/udp"
- "6832:6832/udp"
- "5778:5778"
- "16686:16686"
- "14268:14268"
- "9411:9411"
environment:
- SPAN_STORAGE_TYPE=elasticsearch
- ES_SERVER_URLS=http://elasticsearch:9200
- LOG_LEVEL=debug
networks:
- looklook_net
#prometheus监控 — Prometheus for monitoring
prometheus:
image: prom/prometheus:v2.28.1
container_name: prometheus
environment:
# 时区上海 - Time zone Shanghai (Change if needed)
TZ: Asia/Shanghai
volumes:
- ./deploy/prometheus/server/prometheus.yml:/etc/prometheus/prometheus.yml
- ./data/prometheus/data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
restart: always
user: root
ports:
- 9090:9090
networks:
- looklook_net
#查看prometheus监控数据 - Grafana to view Prometheus monitoring data
grafana:
image: grafana/grafana:8.0.6
container_name: grafana
hostname: grafana
user: root
environment:
# 时区上海 - Time zone Shanghai (Change if needed)
TZ: Asia/Shanghai
restart: always
volumes:
- ./data/grafana/data:/var/lib/grafana
ports:
- "3001:3000"
networks:
- looklook_net
#搜集kafka业务日志、存储prometheus监控数据 - Kafka for collecting business logs and storing Prometheus monitoring data
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.13.4
container_name: elasticsearch
user: root
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- TZ=Asia/Shanghai
- LANG=en_US.UTF-8
- cluster.name="docker-cluster"
- network.host=0.0.0.0
# 开启es跨域
- http.cors.enabled=true
- http.cors.allow-origin="*"
- http.cors.allow-headers=Authorization,Content-Type
volumes:
- ./data/elasticsearch/data:/usr/share/elasticsearch/data
restart: always
ports:
- 9200:9200
- 9300:9300
networks:
- looklook_net
#查看elasticsearch数据 - Kibana to view Elasticsearch data
kibana:
image: docker.elastic.co/kibana/kibana:7.13.4
container_name: kibana
environment:
- elasticsearch.hosts=http://elasticsearch:9200
- TZ=Asia/Shanghai
- i18n.locale=zh-CN # 中文
- LANG=en_US.UTF-8
- server.name=kibana
- server.host="0.0.0.0"
restart: always
networks:
- looklook_net
ports:
- "5601:5601"
depends_on:
- elasticsearch
#消费kafka中filebeat收集的数据输出到es - The data output collected by FileBeat in Kafka is output to ES
go-stash:
image: kevinwan/go-stash:1.0 # if you "macOs intel" or "linux amd"
# image: kevinwan/go-stash:1.0-arm64 # if you "macOs m1" or "linux arm"
container_name: go-stash
environment:
# 时区上海 - Time zone Shanghai (Change if needed)
TZ: Asia/Shanghai
user: root
restart: always
volumes:
- ./deploy/go-stash/etc:/app/etc
networks:
- looklook_net
depends_on:
- elasticsearch
- kafka
#收集业务数据 - Collect business data
filebeat:
image: elastic/filebeat:7.13.4
container_name: filebeat
environment:
# 时区上海 - Time zone Shanghai (Change if needed)
TZ: Asia/Shanghai
user: root
restart: always
entrypoint: "filebeat -e -strict.perms=false" #解决配置文件权限问题 - Solving the configuration file permissions
volumes:
- ./deploy/filebeat/conf/filebeat.yml:/usr/share/filebeat/filebeat.yml
# 此处需指定docker的containers目录,取决于你docker的配置 - The containers directory of docker needs to be specified here, depending on your docker configuration
# 如snap安装的docker,则为/var/snap/docker/common/var-lib-docker/containers - Example if docker is installed by Snap /var/snap/docker/common/var-lib-docker/containers
# - /var/snap/docker/common/var-lib-docker/containers:/var/lib/docker/containers
- /var/lib/docker/containers:/var/lib/docker/containers
networks:
- looklook_net
depends_on:
- kafka
#zookeeper是kafka的依赖 - Zookeeper is the dependencies of Kafka
zookeeper:
image: wurstmeister/zookeeper
container_name: zookeeper
environment:
# 时区上海 - Time zone Shanghai (Change if needed)
TZ: Asia/Shanghai
restart: always
ports:
- 2181:2181
networks:
- looklook_net
#消息队列 - Message queue
kafka:
image: wurstmeister/kafka
container_name: kafka
ports:
- 9092:9092
environment:
- KAFKA_ADVERTISED_HOST_NAME=kafka
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
- KAFKA_AUTO_CREATE_TOPICS_ENABLE=false
- TZ=Asia/Shanghai
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- looklook_net
depends_on:
- zookeeper
#asynqmon asynq延迟队列、定时队列的webui - Asynqmon asynq delay queue, timing queue's webUI
asynqmon:
image: hibiken/asynqmon:latest
container_name: asynqmon
ports:
- 8980:8080
command:
- '--redis-addr=redis:6379'
- '--redis-password=G62m50oigInC30sf'
restart: always
networks:
- looklook_net
depends_on:
- redis
mysql:
image: mysql/mysql-server:8.0.28
container_name: mysql
environment:
# 时区上海 - Time zone Shanghai (Change if needed)
TZ: Asia/Shanghai
# root 密码 - root password
MYSQL_ROOT_PASSWORD: PXDN93VRKUm8TeE7
ports:
- 33069:3306
volumes:
# 数据挂载 - Data mounting
- ./data/mysql/data:/var/lib/mysql
# 日志
command:
# 将mysql8.0默认密码策略 修改为 原先 策略 (mysql8.0对其默认策略做了更改 会导致密码无法匹配)
# Modify the Mysql 8.0 default password strategy to the original strategy (MySQL8.0 to change its default strategy will cause the password to be unable to match)
--default-authentication-plugin=mysql_native_password
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
privileged: true
restart: always
networks:
- looklook_net
#redis容器 - Redis container
redis:
image: redis:6.2.5
container_name: redis
ports:
- 36379:6379
environment:
# 时区上海 - Time zone Shanghai (Change if needed)
TZ: Asia/Shanghai
volumes:
# 数据文件 - data files
- ./data/redis/data:/data:rw
command: "redis-server --requirepass G62m50oigInC30sf --appendonly yes"
privileged: true
restart: always
networks:
- looklook_net
networks:
looklook_net:
driver: bridge
external: true #着重看这里
ipam:
config:
- subnet: 172.16.0.0/16
启动环境
第三方服务,数据库等
docker-compose -f docker-compose-env.yml up -d
启动modd开发服务
项目的开发环境
docker-compose -f docker-compose.ymkl up -d
查询各服务是否启动
http://192.168.160.100:9090/targets
go-zero modd开发配置的更多相关文章
- WCF分布式开发步步为赢(2)自定义托管宿主WCF解决方案开发配置过程详解
上一节<WCF分布式框架基础概念>我们介绍了WCF服务的概念和通信框架模型,并给出了基于自定义托管服务的WCF程序的实现代码.考虑到WCF分布式开发项目中关于托管宿主服务配置和客户端添加引 ...
- API接口开发 配置、实现、测试
Yii2 基于RESTful架构的 advanced版API接口开发 配置.实现.测试 环境配置: 开启服务器伪静态 本处以apache为例,查看apache的conf目录下httpd.conf,找到 ...
- Magento 最佳开发配置
概观 典型的软件开发流程如下: 本地开发机器 > QA /集成服务器 > 预览服务器(可选)> 生产服务器 无论您是在编写新的Magento 2 扩展 还是为代码库做贡献,任何开发人 ...
- 第三百九十四节,Django+Xadmin打造上线标准的在线教育平台—Xadmin后台进阶开发配置2,以及目录结构说明
第三百九十四节,Django+Xadmin打造上线标准的在线教育平台—Xadmin后台进阶开发配置2,以及目录结构说明 设置后台列表页面可以直接修改字段内容 在当前APP里的adminx.py文件里的 ...
- 第三百九十三节,Django+Xadmin打造上线标准的在线教育平台—Xadmin后台进阶开发配置
第三百九十三节,Django+Xadmin打造上线标准的在线教育平台—Xadmin后台进阶开发配置 设置后台某个字段的排序规则 在当前APP里的adminx.py文件里的数据表管理器里设置 order ...
- Ubuntu下opencv的安装及IDEA开发配置
Ubuntu下opencv的安装及IDEA开发配置 环境配置 这篇博客主要介绍Ubuntu下opencv的安装编译,以及IDEA对opencv进行Java开发的环境配置 安装opencv 首先安装o ...
- PyCharm远程开发配置及一些问题的解决方案
PyCharm远程开发配置 具体请参考:https://www.jianshu.com/p/79df9ac88e96 Tips:必须要安装PyCharm专业版 实践过程中遇到的问题 背景 因项目需要, ...
- cocos2dx 开发配置的一些环境变量(mac/linux)
通常开发需要配置一些环境变量,下面把我电脑的部分配置分析一下. 1.android开发配置,ndk,sdk,ant 2.cocos2dx开发配置,cocos2d-x export COCOS2DX_R ...
- Android(安卓)开发通过NDK调用JNI,使用opencv做本地c++代码开发配置方法 边缘检测 范例代码
以前写过两个Android开发配置文档,使用NDK进行JNI开发,这样能够利用以前已经写好的C++代码. 前两篇博客地址: http://blog.csdn.net/watkinsong/articl ...
- Linux下ffmpeg安装与开发配置
Linux下ffmpeg安装与开发配置 1. ffmpeg安装 安装环境: ubuntu 12.04 (1)删除已安装的文件,避免冲突 sudo apt-get remove ffmpeg x26 ...
随机推荐
- 高抗干扰抗噪,段码LCD液晶低功耗驱动IC-VK2C23B,兼容市面上16C23
VK2C23是一个点阵式存储映射的LCD驱动器,可支持最大224点(56SEGx4COM)或者最大416点(52SEGx8COM)的LCD屏. 单片机可通过I2C接口配置显示参数和读写显示数据,也可通 ...
- 浅谈OpenHarmony LiteOS-A内核之基础硬件——中断控制器GIC400
一.前言 OpenAtom OpenHarmony(以下简称"OpenHarmony")采用多内核架构,支持Linux内核的标准系统.LiteOS-A的小型系统.LiteOS-M的 ...
- 1开幕在即 | “万物互联,使能千行百业”2022开放原子全球开源峰会OpenAtom OpenHarmony分论坛
7月27日下午,聚焦开源产业与生态的2022开放原子全球开源峰会OpenAtom OpenHarmony分论坛将在北京亦创国际会展中心盛大开幕. 作为OpenHarmony工作委员会联合生态合作伙伴为 ...
- RabbitMQ 11 死信队列
死信队列 概述 消息队列中的数据,如果迟迟没有消费者来处理,就会一直占用消息队列的空间. 比如抢车票的场景,用户下单高铁票之后,会进行抢座,然后再进行付款,但是如果用户下单之后并没有及时的付款,这张票 ...
- 华为运动健康服务Health Kit 6.10.0版本新增功能速览!
华为运动健康服务(HUAWEI Health Kit)6.10.0 版本新增的能力有哪些? 阅读本文寻找答案,一起加入运动健康服务生态大家庭! 一. 支持三方应用查询用户测量的连续血糖数据 符合申请H ...
- 探索“智”感生活,HMS Core线上Codelabs挑战赛第4期开始!
HMS Core线上Codelabs挑战赛第4期正式开始!我们向所有实践力超强.创新力满满的开发者发出邀请,用你的超级"码"力,解锁更多应用价值! 生活里,我们被手机"秒 ...
- Python设计模式----4.构建者模式
构建者模式: 将一个复杂对象的构造与表现进行分离,利用多个步骤进行创建,同一个构建过程可用于创建多个不同的表现 构建者模式一般由 Director(指挥官)和 Builder(建设者)构成 class ...
- lin-view-ui Vue 2.0 组件库
lin-view-ui 是一款基于 Vue.js 2.0 的前端 UI 组件库,主要集成了平时在开发中使用到的 UI 组件. 特性 基于 Vue 开发的 UI 组件 使用 npm + webpack ...
- logging模块简介python
1 logging模块简介 logging模块是Python内置的标准模块,主要用于输出运行日志,可以设置输出日志的等级.日志保存路径.日志文件回滚等:相比print,具备如下优点: 可以通过设置不同 ...
- 2.css的导入方式
三种导入方式: 1.行内样式:在标签元素中,编写一个style属性,编写样式即可.有多个以分号隔开 <h2 style="color: green">标题</h2 ...