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

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

时间:2023-03-02 09:44:31浏览次数:45  
标签:__ 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/fanshaoO/p/17170714.html

相关文章

  • ABP微服务系列学习-搭建自己的微服务结构(四)
    上篇我们实现了认证服务和网关服务,基本我们的基础服务已经完成了,接下来我们才需要做服务的数据迁移。这里我们需要使用EF的CodeFirst模式。通过DotnetCli的命令去操作:dotn......
  • ABP微服务系列学习-搭建自己的微服务结构(三)
    上一篇我们基础服务初步搭建完毕,接下来我们整一下认证和网关。搭建认证服务认证服务的话,ABPCLI生成的所有模板都包括了一个AuthServer。我们直接生成模板然后微调一下......
  • 深入分析MobileAI图像超分最佳方案:ABPN
    前言 本文设计一种8-bit量化版高效网络并将其部署到移动端,旨在构建一种实时量化模型用于真实场景(比如实时视频超分)。本文转载自AIWalker来源|HappyAIWalker欢迎关......
  • ABP微服务系列学习-搭建自己的微服务结构(一)
    在原本的结构里面,由于默认服务引用的都是ABP原生的模块,所以结构目录里面没有包含modules目录,这里我们添加一个modules目录,用于存放我们的自定义模块。在shared里面,我们再抽......
  • ABP微服务系列学习-搭建自己的微服务结构(二)
    在解决方案根目录添加common.props,这个文件的作用是可以配置项目文件全局的一些属性,如忽略警告,全局PackageReference,语言版本等。<Project><PropertyGroup><LangV......
  • Abp框架使用的坑
     在新的项目开始的时候,第一次从头开始搭建abp框架的项目,使用abpnewProjectName--no-ui命令新建一个不包含ui的abp项目 将JWT导入到项目中,重新写一个类去继承ILogin......
  • Abp搭建多模块,子模块迁移问题
    Abp搭建多模块,子模块迁移问题 Abp搭建多模块,子模块迁移问题第一步,在官网Abp.io下载在一个全新的框架,然后可以根据快速入门来实现属于自己的第一套ABP增删改查.......
  • Abp搭建多模块,子模块迁移问题
    Abp搭建多模块,子模块迁移问题第一步,在官网Abp.io下载在一个全新的框架,然后可以根据快速入门来实现属于自己的第一套ABP增删改查.快速入门官网网址:https://docs.abp.i......
  • .net core abp框架ddd分层如何做ef core迁移和恢复迁移
    一、从模型迁移到数据库1、visualstudio启动项里选择对应的项目,修改appsettings.json里的数据库链接(决定迁移到那个服务器以及数据库)2、打开Nuget管理控制台,执行Add-Mi......
  • ABP VNext DateTime Json处理
    前言api接口返回DateTime默认是yyyy-MM-ddTHH:mm:ss格式,需要转成yyyy-MM-ddHH:mm:ss解决方法Module文件添加context.Services.Configure<AbpJsonOptions>(options=......