/api
Clone the repository:
git clone https://github.com/ibp-network/ibp-monitor.git
cd ibp-monitor
Under the docker
folder, Rename .env.sample
file to .env
, and edit P2P_PUBLIC_HOST
and/or P2P_PUBLIC_IP
variables.
These are going to be used to announce your monitor node's public address, so that it can connect with the other monitor nodes on the network.
You may leave both commented out, or include any or both.
mv .env.sample .env
nano .env
# edit values as necessary
Rest of the default configuration is in config/config.js
. Make a copy of the file, and edit the necessary items:
cp config.js config.local.js
Any item changed in config/config.local.js
will override the default value in config/config.js
For details of the config items, please refer CONFIG.md
The database abstraction layer is powered by Sequelize. The default datastore is MariaDB, supported DBs are:
Notes:
./config/config.local.js
with appropriate DB connection details.After you make the necessary edits in config/config.local.js
for your choice of database, you can use the following commands to install the necessary dependencies and run the migrations:
cd data
node migrate.js
If you instead choose to run the IBP stack using Docker Compose, the ibp-datastore-init
job defined in docker/docker-compose.yml
will initialise the database using Sequelize migration definitions under data/migrations
, which use the data model definitions under data/models
.
config.local.js
as neededInside Docker, the components can access each other by hostnames. When developing locally, you need to edit config/config.local.js
file to define the ports, or set /etc/hosts
as follows:
127.0.0.1 ibp-redis
127.0.0.1 ibp-datastore
127.0.0.1 ibp-monitor-api
If you don't have Redis or MariaDB installed, you can start these individually & manually via Docker. See below for more info.
Clone the repository and install the dependencies:
git clone https://github.com/ibp-network/ibp-monitor.git
cd ibp-monitor
npm install
Each component requires a separate shell window.
Redis & MariaDB
See Docker section if you don't have these running locally, or, amend the config to point to your local services.
API
node api.js
P2P Server
node server.js
Front End (static)
See Docker, this will launch on http://localhost:30001
.
cd frontend
npm install
npm run build # target files will populate ./static
Front End (developer mode)
In developer mode the frontend will proxy /api
to the API service. See ./vue- spa/vite.config.js
if you need to amend this.
Note, in production mode the /api
location is proxied by nginx to the ibp-monitor-api
service.
cd frontend
npm install
npm run serve
BullMQ
See http://localhost:3000/admin/queues
node workers.js
As above, each node.js component can run separately in PM2. (Requires MariaDB and Redis)
pm2 start --name ibp-monitor-api api.js
pm2 start --name ibp-monitor-p2p server.js
pm2 start --name ibp-monitor-workders workers.js
The frontend is located in the ./frontend/static
folder. See development above for building the folder contents.
Point Apache or nginx to serve this folder, with the following config (nginx example):
server {
listen 80;
server_name ibp-monitor.metaspan.io;
location /api {
# to preserve the url encoding, don't put the /api on the end
proxy_pass http://ibp-monitor-api:30002;
}
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
Docker files and docker-compose.yml
are in the ./docker
folder. Service names:
Under the docker
folder, Rename .env.sample
file to .env
, and edit P2P_PUBLIC_HOST
and/or P2P_PUBLIC_IP
variables.
These are going to be used to announce your monitor node's public address, so that it can connect with the other monitor nodes on the network.
You may leave both commented out, or include any or both.
mv .env.sample .env
nano .env
# edit values as necessary
cd docker # you need to be in the docker directory!
docker compose up
Use ctrl-c
to stop services.
Use -d
flag with compose (docker compose up -d
) for detach to let the services run in background.
cd docker # you need to be in the docker directory!
docker compose up <service name> # optional `-d` flag
(Tested on Node v16)
git clone https://github.com/ibp-network/ibp-monitor.git
cd ibp-monitor
npm install
cd config
# edit config.local.js to suit your needs
cp config.js config.local.js
# initialise the datastore
cd data
node migrate.js
cd ..
# run the server
node server.js
# run the workers
node workers.js
# run the API
node api.js
# run the frontend
cd frontend
npm install
npm run dev
pm2 save # to persist your jobs
pm2 list # see the running jobs
pm2 logs ibp-monitor
Implememt scoring
Implement alerting
implement status / metrics - some basic metrics available at /api/metrics/{serviceId}
.
implement prometheus (or similar) api - Done, each service has a link to the Prometheus data.
how to create your own peerId - Done, the server will create keys/peer-id.json
at 1st startup.
Peers should sign status updates - This is configured in libp2p.pubsub.signMessages: true
.