PAI-NET server installation

You are here:
< All Topics
Table of Contents

Installation Guide

If you wish to create a private network for your Bots, you can install PAI-NET server, and register your bots to this server.

To set up the PAI-NET properly we recommend to install it on a new server instance.

PAI-NET uses a NodeJS Web application to handle the logic, WebSocket communicates with bots, and MongoDB to store information about the network.

What to install?

  • PAI-NET Data Base – MongoDB
  • PAI-NET Web Server – NodeJS Application
  • File Service Bot (recommended) – Bot to store media and backups
  • Monitor Bot (recommended) – Monitor all bot’s activity
  • Sawtooth BlockChain (optional)

Step by step guide:

This procedure explains how to set up PAI-NET Server on Ubuntu 18.04. The PAI-NET environment is a single instance with the following dockers:

  • Database
  • Web Application
  • Bots
PAI NET ENV

Create new instance:

Create new server instance and connect to the terminal via SSH (make sure you have sudo permission).

Host configuration

The first thing we need to install is Docker. Open the terminal and paste this command:

    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    sudo apt-get update
    apt-cache policy docker-ce
    sudo apt-get install docker-ce
    sudo usermod -aG docker $USER

In order to set up a bot on the host, you will need to set up the PAI-Environment: Please refer to the PAI-ENV setup guide.

Docker Containers

After you set up the host, let’s start to create Docker containers for the different services.

Database

After installing the docker you will need to create a MongoDB container.

Run this command:

please change the username and password in the script below

    docker run -itd -p :27017 --name CONTAINER-NAME -e MONGO_INITDB_ROOT_USERNAME={YourUsername} -e MONGO_INITDB_ROOT_PASSWORD={YourPassword} mongo:3.7
Web Server – NodeJS Application

The web application is responsible for the communication between bots.

To install PAI-NET Web application, you will need to set up the following services:

  • Git
  • NodeJS
  • npm
  • Forever (forever package for running the web application)
  • Python

After installing all the services above, we need to download the PAI-node-server repository.

Run this command:

    git clone https://github.com/PAI-Tech/PAI-node-server.git

Make sure the repository has been downloaded and continue to install all node packages:

    cd PAI-node-server
    npm install --production
    mkdir ssl

Now, in order to run PAI-NET over SSL, we will need to generate the SSL certificate.

Please refer to this guide for generating certification using certbot. // TODO: create certbot guide

After you created the certificate, copy the certificate files (3 files) to the repository directory.

OK, let’s start configuring the Web Application, run this command in the repository directory:

    npm run init

This command will ask you to configure PAI-NET web application. Please answer the questions and fill the information.

notice! you will need to use the username and password that you created in the previous step when installing the MongoDB container. It is important to generate the SSL certificate before configuring the Web Application

Bootstrap script:

    npm run bootstrap

This command will create basic data and settings for PAI-NET to run.

OK, We are all set, let’s run the web application:

    npm start

Test Your PAI-NET

Let’s try to connect to our PAI-NET Server, Go to browser and type the following URL:

https://{yourdomain}/ping

If you get a JSON response that echoes this: {"ping": true} then your Server routing is configured properly.


To validate the connection to the database, please browse to this URL:

https://{yourdomain}/api/avatars

If you get a JSON response then your Server Database is configured properly.

Create Bots