console/

directory
v1.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2020 License: Apache-2.0

README

Console

  • Go环境
    • go 1.13
    • export GOSUMDB=off
    • export GOPROXY=https://mirrors.aliyun.com/goproxy/,direct

目录

架构

快速开始

Docker Compose启动

使用docker-compose快速启动服务,适合搭建本地开发环境,省去每个服务去做启动管理的烦恼,Compose启动后可以对单个服务进行重新编译启动。

Compose命令参考

Compose包含以下服务:

  • Etcd注册中心
    • etcd,使用docker镜像bitnami/etcd
  • API网关
    • gateway,使用docker镜像hbchen/starter-kit-gateway
  • Console Web
    • web
  • Console API
    • api
  • Account SRV
    • account

Compose启动服务

1.首次运行创建Docker网络

docker network create starter-kit-console

2.Go编译,编译Console项目全部服务,包括webapiaccount服务

使用Dockerfile编译太慢,所以编译还是选择使用本机环境

make build

3.启动服务

p参数为项目名称,可以自己定义

make start p=starter-kit-console
# 或
docker-compose -p starter-kit-console up

4.服务测试

重新编译并启动服务

例如要重启api服务 注意:web服务前端没有自动编译,需要单独运行make vue更新前端

方法一: 使用Makefilemake restart命令,p项目名称,s服务名称

 make restart p=starter-kit-console s=api

方法二: 使用docker-compose分步操作,stop停止服务、Go编译、build重新构建服务镜像、up启动服务

docker-compose -p starter-kit-console stop api
cd api && make build_linux && cd ..
docker-compose -p starter-kit-console build api
docker-compose -p starter-kit-console up -d --no-deps --force-recreate api

Compose常用命令

# 移除compose file中没有定义的容器
docker-compose -p starter-kit-console down --remove-orphans
编译启动

如果使用Etcd注册中心需要自己维护

1.运行网关

网关

$ cd gateway

# 编译
$ make build

# API网关(二选一)
$ make run_api                                  # 默认mdns + http
$ make run_api registry=etcd transport=tcp      # 使用etcd + tcp

2.运行服务

  • Web服务
    • console/web
  • API服务
    • console/api
  • Account服务
    • console/account

注:registrytransport选择与网关一致

$ cd {指定服务目录}

# 运行服务(二选一)
$ make build run                                # 默认mdns + http
$ make build run registry=etcd transport=tcp    # 使用etcd + tcp

Makefile说明

$ make build                                    # 编译
$ make run                                      # 运行
$ make run registry=etcd transport=tcp          # 运行,指定registry、transport

$ make build run                                # 编译&运行
$ make build run registry=etcd transport=tcp    # 编译&运行,指定registry、transport

$ make vue statik                               # 前端编译,并打包statik.go文件

$ make docker tag=xxx/xxx:v0.0.1
服务测试

注:console API由于有认证不能直接访问

Proto管理

项目.proto文件统一在pb目录下,协议生成的out输出到指定子项目位置gen=path

# console目录运行make proto输出到子项目的genproto
make proto gen=api/genproto
make proto gen=account/genproto

# 或在子项目目录运行make proto,实际仍是调用console下的make proto
cd api
make proto

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL