P
P
Pryby2021-05-06 22:18:48
go
Pryby, 2021-05-06 22:18:48

Docker compose does not start, writes that the page is not available, how to fix it?

I access this path localhost:8081/api/v1/clients

version: '3.3'

services:
  db-enterprise:
    image: pryby/db:latest
    networks:
      - enterprise-network
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=root
      - POSTGRES_DB=enterprise
    ports:
      - 5432:5432
    container_name: db-enterprise
  backend:
    image: pryby/backend:latest
    ports:
      - 8080:8080
    container_name: backend
    environment:
      - LISTEN=0.0.0.0:8080
      - DB_USERS_HOST=db-enterprise
      - DB_USERS_PORT=5432
      - DB_USERS_USER=postgres
      - DB_USERS_DBNAME=enterprise
      - DB_USERS_PASSWORD=root
      - DB_USERS_SSL=disable
    depends_on:
      - db-enterprise
    networks:
      - enterprise-network
  gateway:
    image: pryby/client:latest
    ports:
      - 8081:8081
    container_name: gateway
    depends_on:
      - backend
    environment:
      - backend=backend:8080
      - LISTEN=0.0.0.0:8081
    networks:
      - enterprise-network

networks:
  enterprise-network:
    name: enterprise-network

the client looks like this:

conn, err := grpc.Dial("localhost:8080", grpc.WithInsecure(), grpc.WithBlock())
  if err != nil {
    log.Fatal(err)
  }
  defer conn.Close()

  grpcMux := runtime.NewServeMux()
  api.RegisterAllServiceHandler(context.Background(), grpcMux, conn)
  log.Fatal(http.ListenAndServe("localhost:8081", grpcMux))

server like this:

ctx := context.Background()
  ctx, error := context.WithCancel(ctx)
  ctx, error = context.WithTimeout(ctx, time.Second*30)
  if error != nil {
    log.Println(error)
  }

  listener, err := net.Listen("tcp", ":8080")
  if err != nil {
    log.Fatal(err)
  }

  server := grpc.NewServer()
  conn, err := connectToDbWithTimeout(ctx)
  if err != nil {
    log.Fatal(err)
  }
  api.RegisterAllServices(server, conn)

  if err = server.Serve(listener); err != nil {
    log.Fatal(err)
  }

I tried everything already, I can not understand why it does not work

609440cf8b470404231099.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alfss, 2021-05-08
@alfss

grpc.Dial("localhost:8080 Problem here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question