首页 > 其他分享 >ABP微服务系列学习-使用Tye启动微服务

ABP微服务系列学习-使用Tye启动微服务

时间:2023-03-16 10:36:58浏览次数:38  
标签:__ name .. Tye ABP tye 系列学习 localhost FunShow

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信息



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



认证服务


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

标签:__,name,..,Tye,ABP,tye,系列学习,localhost,FunShow
From: https://www.cnblogs.com/wl-blog/p/17221338.html

相关文章

  • .Net Core微服务化ABP之六——处理Authentication
    上篇中我们已经可以实现sso,并且为各个服务集成sso认证。本篇处理权限系统的角色问题,权限系统分两层,第一层为整体系统角色权限,区分app用户、后台用户、网站用户的接口权限,第......
  • ABP 结合 MongoDB 集成依赖注入
    1.我们再ABP项目添加一个.NETCore类库 类库名自定定义,我这里定义为 TexHong_EMWX.MongoDb添加NuGet包。ABPmongocsharpdriver  添加 AbpMongoDbConfigurati......
  • 在Abp中使用依赖注入
    依赖注入是一种设计模式,这里主要讨论如何在Abp中使用依赖注入。注册依赖项在Abp中我们有很多种方法来注册依赖项,大多数情况下通过约定来注册依赖项就足够了。这也是......
  • ABP 动态 WebApi 隐藏接口的方法(一)
    在ABP实际开发过程中既有可能会遇到不希望将某些方法暴露,那么就需要想办法将接口隐藏起来。方法一:通过修改修饰符实现。例如将方法修改为private,这种方式比较常用。但这......
  • ABP微服务系列学习-对接Apollo配置中心
    前面我们把服务都已经成功启动,并且对接前端Angular界面。但是在微服务结构中,多个服务意味着需要配置多个配置文件,这时就需要引入配置中心这玩意了。配置中心有很多现成的方......
  • ABP微服务系列学习-搭建自己的微服务结构(一)
    在原本的结构里面,由于默认服务引用的都是ABP原生的模块,所以结构目录里面没有包含modules目录,这里我们添加一个modules目录,用于存放我们的自定义模块。在shared里面,我们再抽......
  • 【愚公系列】2022年03月 .NET架构班 020-ABP vNext 虚拟文件系统
    【摘要】前言虚拟文件系统可以管理文件系统(磁盘)上实际不存在的文件。它主要用于将(js,css,image,cshtml…)文件嵌入到程序集中,并在运行时将它们用作物理文件。一、集成虚拟......
  • ABP使用SQLite本地数据库
    1、修改EFCore中的依赖,添加Sqlite的依赖,移除原先的sqlserver的依赖  2、修改配置中的使用  3、修改Web.Host中的配置文件中appsettings.json中数据库的地址 ......
  • 为ABP框架配置数据库
    目录创建标准的EFCore数据库上下文连接字符串定义隔离的上下文多数据库支持和配置Freesql配置服务在 AbpBase.Database 中,通过Nuget添加以下几个库:版本......
  • Avalonia集成Prism与Abp
    Wpf中使用appsettings.json配置文件以及UserSecrets通过ConfigurationBuilder读取配置信息varbuilder=newConfigurationBuilder().SetBasePath(AppDomain.Curre......