How to run an API Endpoint
Running an API Endpoint is a similar process as setting up a validator node.
The only differences are the ROLE
environment variable. The ROLE
environment variable should be set to 0
for an API Endpoint.
We also dont need to register a wallet as a validator and pay registration fee.
Prerequisites
-
Install Docker (opens in a new tab)
-
Install docker-compose (opens in a new tab) as well if it is not installed with Docker by default
Get the official Docker Image: iconloop/icon2-node
System Requirements
CPU: minimum 4core, recommend 8core +
RAM: minimum 16GB, recommend 32GB +
DISK : minimum SSD 2.5TB, recommend SSD 3TB +
Network: minimum 1Gbps, recommend 2Gbps +
External Communications
TCP 7100: TCP port used for peer-to-peer connection between peer nodes.
TCP 9000: JSON-RPC or RESTful API port serving application requests.P-Rep must allow TCP connections to port 7100 and 9000 of an external host. ( Use 0.0.0.0/0 for a source from any network )
Getting started
Create a working folder in your server on a disk with enough space as detailed in the system requirements.
For this guide we will use the following structure:
mkdir ~/icon-api-endpoint
Change to the working directory
cd ~/icon-api-endpoint
Create a docker-compose.yml
file in the working directory.
touch docker-compose.yml
Open docker-compose.yml in a text editor and add the following content:
version: "3"
services:
prep:
image: iconloop/icon2-node
container_name: "icon2-node"
network_mode: host
restart: "on-failure"
environment:
SERVICE: "MainNet" # MainNet, SejongNet ## network type
GOLOOP_LOG_LEVEL: "debug" # trace, debug, info, warn, error, fatal, panic
KEY_STORE_FILENAME: "INPUT_YOUR_KEY_STORE_FILENAME" # optional, a wallet will be generated for you if you don't have one
KEY_PASSWORD: "INPUT_YOUR_KEY_PASSWORD" # optional, a wallet will be generated for you if you don't have one
FASTEST_START: "true" # It can be restored from latest Snapshot DB.
ROLE: 0 # Validator = 3, API Endpoint = 0
cap_add:
- SYS_TIME
volumes:
- ./data:/goloop/data # mount a data volumes
- ./config:/goloop/config # mount a config volumes ,Put your used keystore file here.
- ./logs:/goloop/logs
Run the following command to start the ICON2 node and wait for the entire ledger to locally sync.
$ docker-compose pull && docker-compose up -d
To see the logs of the ICON2 node you can execute
$ tail -f logs/booting.log
$ tail -f logs/goloop.log
The following folder structure will be created:
.
βββ docker-compose.yml
βββ config # configuration files
β βββ keystore.json # Import your keystore file
βββ data # block data
β βββ 1
β βββ auth.json
β βββ cli.sock
β βββ ee.sock
β βββ rconfig.json
βββ logs # log files
βββ booting.log
βββ health.log # health state log
βββ chain.log # goloop chain action logs
βββ download.log
βββ download_error.log # download
βββ goloop.log # goloop's log file
Docker environments settings
Name | default | type | required | description |
---|---|---|---|---|
SERVICE | MainNet | str | false | Service Name - (MainNet, SejongNet) |
ROLE | 0 | int | true | Role of running node. 0: Citizen, 3: P-Rep |
CONFIG_URL | str | false | ||
CONFIG_URL_FILE | default_configure.json | str | false | |
CONFIG_LOCAL_FILE | configure.json | str | false | |
IS_AUTOGEN_CERT | false | bool | false | Automatically generate certificates |
FASTEST_START | false | bool | false | Download snapshot DB |
KEY_STORE_FILENAME | keystore.json | str | true | keystore.json file name |
KEY_PASSWORD | str | true | password of keystore.json file | |
USE_NTP_SYNC | True | bool | false | Whether to use NTP in container |
NTP_SERVER | str | false | NTP Server | |
NTP_REFRESH_TIME | int | false | ntp refresh time | |
SLACK_WH_URL | str | false | slack web hook url - If a problem occurs, you can receive an alarm with a slack. | |
USE_HEALTH_CHECK | True | bool | false | Whether to use health check |
CHECK_TIMEOUT | 10 | int | false | sec - TIMEOUT when calling REST API for monitoring |
CHECK_PEER_STACK | 6 | int | false | sec - Stack value to check the peer for monitoring. |
CHECK_BLOCK_STACK | 10 | int | false | sec - Stack value to check the block for monitoring. |
CHECK_INTERVAL | 10 | int | false | sec - check interval for monitoring |
CHECK_STACK_LIMIT | 360 | int | false | count - count- Restart container when stack value is reached |
GOLOOP_LOG_LEVEL | debug | str | false | Log Level - (trace,debug,info,warn,error,fatal,panic |
LOG_OUTPUT_TYPE | file | str | false | sec - check interval for monitoring |