Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run this explorer-api on my local? #21

Closed
SWS-5007 opened this issue Jan 25, 2023 · 12 comments
Closed

How to run this explorer-api on my local? #21

SWS-5007 opened this issue Jan 25, 2023 · 12 comments

Comments

@SWS-5007
Copy link

Hi,
I am going to run this api on my local, win_10.
How should I do this?
Please let me know in detail step by step.
Best.

@SWS-5007
Copy link
Author

When I run this command, docker-compose up --build, as Readme, I am getting error below.

...

  • 495af11a3eac Downloading [==================================================>] 313.8k... 152.2s
  • 18b045ddb54d Downloading [==================================================>] 1.166M... 152.2s
  • f49c2d6d086c Download complete 152.2s
  • 14ed0c386119 Download complete 152.2s
    unexpected EOF

And also, I run this command, export API_DOCKER_FILE="./docker/api/Dockerfile.query.logging" API_DOCKER_IMAGE="polkascan/explorer-api-query-logging" API_DOCKER_COMMAND="bash -c '/usr/src/start-api-query-logging.sh'" && docker-compose up --build, I am getting same error above.

What is wrong?
How can I solve this problem?

@SWS-5007
Copy link
Author

Here is my docker-composer.yml file.

version: "3"

services:
  db:
    image: mysql
    hostname: mysql
    environment:
      MYSQL_ROOT_PASSWORD: aXMHcwPm4fMJa
      MYSQL_DATABASE: test_explorer
    ports:
      - "3307:3306"

  redis:
    image: "redis:latest"

  polling:
    build:
      context: .
      dockerfile: ./docker/polling/Dockerfile
    image: polkascan/explorer-polling-beta
    command: python polling.py
    depends_on:
      - redis
      - db
      - api
    environment:
      - DB_USERNAME=test_root
      - DB_NAME=test_explorer
      - DB_HOST=mysql
      - DB_PORT=3306
      - DB_PASSWORD=aXMHcwPm4fMJa
      - BROADCAST_URI=redis://redis:6379
      - CHAIN_ID=polkadot
      - SENTRY_PROJECT_NAME=explorer-polling-v2
      - SENTRY_SERVER_NAME=polkadapt
      - SENTRY_DSN=

  api:
    build:
      context: .
      dockerfile: ${API_DOCKER_FILE:-./docker/api/Dockerfile}
    image: ${API_DOCKER_IMAGE:-polkascan/explorer-api-beta}
    command: ${API_DOCKER_COMMAND:-bash -c "/usr/src/start-api.sh"}
    ports:
      - "8000:8000"
    depends_on:
      - redis
      - db
#    # Note: enable when running with Signoz telemetry
#    networks:
#        - default
#        - clickhouse-setup_default
    environment:
      - DB_USERNAME=test_root
      - DB_NAME=test_explorer
      - DB_HOST=mysql
      - DB_PORT=3306
      - BLOCK_LIMIT_COUNT=500000
      - HTTP_MOUNT=/graphql/
      - WS_MOUNT=/graphql-ws/
      - DB_HARVESTER_NAME=test_db
      - DB_PASSWORD=aXMHcwPm4fMJa
      - DOMAIN=localhost
      - SERVER_ADDR=localhost
      - SERVER_PORT=8000
      - WEBSOCKET_URI=ws://localhost:8000
      - BACKEND_CORS_ORIGINS=[]
      - BROADCAST_URI=redis://redis:6379
      - API_SQLA_URI=mysql+pymysql://test_root:[email protected]:3306/test_explorer?charset=utf8mb4
      - CHAIN_ID=polkadot
      - SENTRY_PROJECT_NAME=explorer-api-v2
      - SENTRY_SERVER_NAME=polkadapt
      - SENTRY_DSN=

##Note: enable when running with Signoz telemetry
#networks:
#    clickhouse-setup_default: # external signoz created network
#        external: true

@matthijsb
Copy link
Collaborator

This project is only tested on linux based systems, it seems there is a mismatch in EOF handling between windows / posix systems. You can run this on windows, but you should use WSL 2: https://learn.microsoft.com/en-us/windows/wsl/install

@SWS-5007
Copy link
Author

This project is only tested on linux based systems, it seems there is a mismatch in EOF handling between windows / posix systems. You can run this on windows, but you should use WSL 2: https://learn.microsoft.com/en-us/windows/wsl/install

Hi,
I installed Ubuntu on VM and run this api with docker-compose up --build command, I am getting same error.

unexpected EOF

What is wrong?

@SWS-5007
Copy link
Author

One more question.
To run this API, I am running only this command, docker-compose up --build in root of explorer-api.

Then, I can see many sections in README.MD of explorer-api repo.
For example, Add GraphQL query logging, Add telemetry using Signoz etc.
So Which way is the best to run this api?
Can't I run this api by using only docker-compose up --build as I can see first of this README.MD

@matthijsb
Copy link
Collaborator

Running using "docker-compose up --build" should work, we've tested this on WSL 2, native Ubuntu and MacOS. Which Ubuntu version did you use? And did you do a fresh checkout when running docker-compose?

@SWS-5007
Copy link
Author

SWS-5007 commented Feb 6, 2023

Running using "docker-compose up --build" should work, we've tested this on WSL 2, native Ubuntu and MacOS. Which Ubuntu version did you use? And did you do a fresh checkout when running docker-compose?

I am using the Ubuntu 22.04 on AWS.
And did you do a fresh checkout when running docker-compose?
How can I do this?

@matthijsb
Copy link
Collaborator

matthijsb commented Feb 6, 2023

Just tested on WSL 2 (ubuntu 20.04):

git clone https://github.com/polkascan/explorer-api.git

modified the docker-compose.yml:

`version: "3"

services:
#db:

image: mysql

hostname: mysql

environment:

MYSQL_ROOT_PASSWORD: root

MYSQL_DATABASE: explorer_api

ports:

- "3307:3306"

redis:
image: "redis:latest"

polling:
build:
context: .
dockerfile: ./docker/polling/Dockerfile
image: polkascan/explorer-polling-beta
command: python polling.py
depends_on:
- redis
# - db
- api
environment:
- DB_USERNAME=test_root
- DB_NAME=test_explorer
- DB_HOST=81.181.255.414
- DB_PORT=3306
- DB_PASSWORD=aXMHcwPm4fMJa
- BROADCAST_URI=redis://redis:6379
- CHAIN_ID=polkadot
- SENTRY_PROJECT_NAME=explorer-polling-v2
- SENTRY_SERVER_NAME=polkadapt
- SENTRY_DSN=

api:
build:
context: .
dockerfile: ${API_DOCKER_FILE:-./docker/api/Dockerfile}
image: ${API_DOCKER_IMAGE:-polkascan/explorer-api-beta}
command: ${API_DOCKER_COMMAND:-bash -c "/usr/src/start-api.sh"}
ports:
- "8000:8000"
depends_on:
- redis
#- db

# Note: enable when running with Signoz telemetry

networks:

- default

- clickhouse-setup_default

environment:
  - DB_USERNAME=test_root
  - DB_NAME=test_explorer
  - DB_HOST=81.181.255.414
  - DB_PORT=3306
  - BLOCK_LIMIT_COUNT=500000
  - HTTP_MOUNT=/graphql/
  - WS_MOUNT=/graphql-ws/
  - DB_HARVESTER_NAME=polkascan
  - DB_PASSWORD=aXMHcwPm4fMJa
  - DOMAIN=localhost
  - SERVER_ADDR=localhost
  - SERVER_PORT=8000
  - WEBSOCKET_URI=ws://localhost:8000
  - BACKEND_CORS_ORIGINS=[]
  - BROADCAST_URI=redis://redis:6379
  #- API_SQLA_URI=mysql+pymysql://root:root@mysql:3306/explorer_api?charset=utf8mb4
  - API_SQLA_URI=mysql+pymysql://test_root:[email protected]:3306/test_explorer?charset=utf8mb
  - CHAIN_ID=polkadot
  - SENTRY_PROJECT_NAME=explorer-api-v2
  - SENTRY_SERVER_NAME=polkadapt
  - SENTRY_DSN=

##Note: enable when running with Signoz telemetry
#networks:

clickhouse-setup_default: # external signoz created network

external: true`

Then run it:

docker-compose up --build

But can't test further since the IP is probably a private one:

polling_1 | ERROR:main:(2003, "Can't connect to MySQL server on '81.181.255.414'")
polling_1 | WARNING:main:Finished call to 'main.get_connection' after 13.128(s), this was the 14th time calling it.
api_1 | ERROR:main:(pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on '81.181.255.414' ([Errno -2] Name or service not known)")
api_1 | (Background on this error at: http://sqlalche.me/e/13/e3q8)
api_1 | WARNING:main:Finished call to 'main.init' after 14.265(s), this was the 15th time calling it.

@SWS-5007
Copy link
Author

SWS-5007 commented Feb 6, 2023

What is wrong yet?
What should I do now?

@arjanz
Copy link
Member

arjanz commented Feb 6, 2023

From the looks of it, nothing is wrong? Maybe the debug info is a bit confusing (executed SQL queries) but the service is running (Uvicorn running on http://0.0.0.0:8000).

Be aware this only started the API and not the harvester, so no data will be processed. I assume you have the harvester running elsewhere?

If not, the docker-compose containing all necessary services can be found here: https://github.com/polkascan/explorer/blob/main/docker-compose.yml

Again, my recommendation would be in your case to just run mentioned docker-compose file with docker-compose up -d --build, and also use the MySQL DB included in this docker-compose file on a AWS EC2, then no further DevOps knowledge is required.

@SWS-5007
Copy link
Author

SWS-5007 commented Feb 7, 2023

Now, I am trying to run this explorer with harvester and api.
I am executing the docker compose up --build command in the root of explorer.
But I am issue error below.
image
As you can see here, this command doesn't work well.
What is wrong?

@matthijsb
Copy link
Collaborator

Im closing this here since it is not explorer-api related, for more info see here:

polkascan/explorer#24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants