Code Monkey home page Code Monkey logo

go-todolist's Introduction

  1. docker run --name mongo -p 27017:27017 mongo

  2. docker run -p 4222:4222 -ti nats:latest 消息中间件

    export MICRO_BROKER=nats
    export MICRO_BROKER_ADDRESS=127.0.0.1:4222

  3. 因为使用了 etcd 来注册发现。所以需要填配置环境变量。两个方式都可以

    1. 环境变量方式(我们从用这个方式)
    • export MICRO_REGISTRY=etcd
    • export MICRO_REGISTRY_ADDRESS=127.0.0.1:2379
    1. 命令参数方式
    • micro --registry=etcd --registry_address=127.0.0.1:2379 api --handler=http
  4. task-srv: srv 服务 go run main.go

    如果编译的话:

    1. protoc --proto_path=. --micro_out=${MODIFY}:. --go_out=${MODIFY}:. proto/task/task.proto
    2. protoc-go-inject-tag -input=proto/task/task.pb.go
    3. go build -o task-srv main.go
  5. achievement-srv: srv 消费者(事件监听)
    go run main.go

  6. task-api: 提供 restful api 服务。端口号 8888 go run main.go

  7. 启动反向代理。类似 nginx。端口号 8080

    因为使用了环境变量使用 etcd 来发现

    micro api --handler=http

  8. micro web 启用 web 管理界面工具

etcd

rm -rf /tmp/etcd-data.tmp && mkdir -p /tmp/etcd-data.tmp && \
  docker run \
  -p 2379:2379 \
  -p 2380:2380 \
  --mount type=bind,source=/tmp/etcd-data.tmp,destination=/etcd-data \
  --name etcd-gcr-v3.4.13 \
  -d \
  quay.io/coreos/etcd:v3.4.13 \
  /usr/local/bin/etcd \
  --name s1 \
  --data-dir /etcd-data \
  --listen-client-urls http://0.0.0.0:2379 \
  --advertise-client-urls http://0.0.0.0:2379 \
  --listen-peer-urls http://0.0.0.0:2380 \
  --initial-advertise-peer-urls http://0.0.0.0:2380 \
  --initial-cluster s1=http://0.0.0.0:2380 \
  --initial-cluster-token tkn \
  --initial-cluster-state new \
  --log-level info \
  --logger zap \
  --log-outputs stderr

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.