Tye是微软开源的一款开发人员工具, 能够用于简化微服务以及分布式应用程序的开发、测试以及部署过程。
Tye 的首要目标是简化微服务的开发,具体方式包括仅用一行命令执行多项服务、在容器中使用依赖项目,以及使用简单的方法探索其他服务的地址。

安装tye

首先我们安装tye,使用dotnet cli命令。

dotnet tool install -g Microsoft.Tye --version "0.11.0-alpha.22111.1"

安装完后即可使用tye命令

配置tye

首先我们使用tye init命令初始化tye.yaml配置文件
结构大致入下:

name: funshow
services:
- name:
project:
- name:
project:

我们需要在配置文件中添加我们的服务,包括绑定端口,环境变量等。
这里完整的配置文件如下:

name: FunShow
services:
- name: auth-server
project: apps/auth-server/src/FunShow.AuthServer/FunShow.AuthServer.csproj
bindings:
- protocol: https
port: 44322
env:
- Kestrel__Certificates__Default__Path=../../../../etc/dev-cert/localhost.pfx
- Kestrel__Certificates__Default__Password=e8202f07-66e5-4619-be07-72ba76fde97f
- name: administration-service
project: services/administration/src/FunShow.AdministrationService.HttpApi.Host/FunShow.AdministrationService.HttpApi.Host.csproj
bindings:
- protocol: https
port: 44367
env:
- Kestrel__Certificates__Default__Path=../../../../etc/dev-cert/localhost.pfx
- Kestrel__Certificates__Default__Password=e8202f07-66e5-4619-be07-72ba76fde97f
- name: identity-service
project: services/identity/src/FunShow.IdentityService.HttpApi.Host/FunShow.IdentityService.HttpApi.Host.csproj
bindings:
- protocol: https
port: 44388
env:
- Kestrel__Certificates__Default__Path=../../../../etc/dev-cert/localhost.pfx
- Kestrel__Certificates__Default__Password=e8202f07-66e5-4619-be07-72ba76fde97f
- name: logging-service
project: services/logging/src/FunShow.LoggingService.HttpApi.Host/FunShow.LoggingService.HttpApi.Host.csproj
bindings:
- protocol: https
port: 45124
env:
- Kestrel__Certificates__Default__Path=../../../../etc/dev-cert/localhost.pfx
- Kestrel__Certificates__Default__Password=e8202f07-66e5-4619-be07-72ba76fde97f
- name: web-gateway
project: gateways/web/src/FunShow.WebGateway/FunShow.WebGateway.csproj
bindings:
- protocol: https
port: 44325
env:
- Kestrel__Certificates__Default__Path=../../../../etc/dev-cert/localhost.pfx
- Kestrel__Certificates__Default__Password=e8202f07-66e5-4619-be07-72ba76fde97f

bindings表示我们绑定https以及端口号。
env里面配置了我们的本地开发HTTPS证书。

创建本地证书

上面配置里面我们有加载本地证书,那么怎么创建证书呢,在tye仓库中也有说明
https://github.com/dotnet/tye/blob/main/docs/tutorials/hello-tye/00_run_locally.md#generate-the-certificate
仓库中是在linux环境,但是在windows环境中localhost.conf是一样的

[req]
default_bits = 2048
default_keyfile = localhost.key
distinguished_name = req_distinguished_name
req_extensions = req_ext
x509_extensions = v3_ca [req_distinguished_name]
commonName = Common Name (e.g. server FQDN or YOUR name)
commonName_default = localhost
commonName_max = 64 [req_ext]
subjectAltName = @alt_names [v3_ca]
subjectAltName = @alt_names
basicConstraints = critical, CA:false
keyUsage = keyCertSign, cRLSign, digitalSignature,keyEncipherment [alt_names]
DNS.1 = localhost
DNS.2 = 127.0.0.1

创建etc/dev-cert目录,在目录下添加localhost.conf文件,内容如上。
然后执行dotnet dev-certs命令

dotnet dev-certs https -v -ep localhost.pfx -p e8202f07-66e5-4619-be07-72ba76fde97f -t

就会在目录下面生成localhost.pfx证书文件。

使用tye运行微服务

在目录下面执行tye运行命令

tye run --watch

效果如下:



当然运行服务前我们需要把我们的基础服务都启动,如数据库,消息队列,redis等。
在tye dashboard可以查看服务的日志以及Metrics信息




下面是服务启动页面。
网关服务




认证服务



到这我们后端功能就基本完成啦

最新文章

  1. 2016 Multi-University Training Contests
  2. 【我所理解的Cocos2d-x】第六章 精灵Sprite 读书笔记
  3. 代码开光,Orz
  4. ssh 无密码登录远程服务器
  5. JS笔记 入门第二
  6. Sqoop mysql 数据导入到hdfs
  7. C#操作Xml:XPath语法 在C#中使用XPath示例
  8. Unity 类似FingerGestures 的相机跟随功能
  9. netty4.x 传输文件
  10. 4.基于梯度的攻击——MIM
  11. Linux下通过vi修改只读文件
  12. Gradient Boosting, Decision Trees and XGBoost with CUDA ——GPU加速5-6倍
  13. MFC如何在树形图边上添加动态小地图
  14. js实时显示鼠标坐标
  15. Host '127.0.0.1' is not allowed to connect to this MySQL server
  16. IOS初级:story board的跳转
  17. RAW转换成RGB
  18. django2.1---后台管理 admin 字段内容过长,省略号替代
  19. 使用Xcode 查看objective-C的汇编代码
  20. [k8s]kube-router替代kube-proxy实现svc网络和pod网络

热门文章

  1. C#不提升自己程序的权限实现操作注册表
  2. DC-9靶场练习
  3. 异常处理语法结构、yield生成器及其表达式
  4. 微软出品自动化神器【Playwright+Java】系列(六) 之 字符输入、单元素键盘事件操作、上传文件、聚焦、拖拽、悬浮操作
  5. Mybatis-9.28
  6. Spring学习笔记 - 第三章 - AOP与Spring事务
  7. 聊一聊 SQLSERVER 的行不能跨页
  8. Web初级——html常用标签归类
  9. vulnhub靶场之VULNCMS: 1
  10. 解决 requests cookies 为空的坑