Source code setup
The installation from source code is designed for anyone wishing to develop on the Klayr Core codebase. It also comes with an extensive test-suite which is described in the README.md. An installation performed from the source code enables a developer to work on the latest codebase of Klayr Core, which may not have been tagged for a release yet.
Pre-Install
To complete the installation certain prerequisites need to be fulfilled. If you have already performed these, then please proceed to the Installation section.
Requirements
- Supported Platforms
-
-
Ubuntu 20.04 (LTS) x86_64
-
Ubuntu 22.04 (LTS) x86_64
-
MacOS x86_64
-
- Node.js
-
-
18
-
The following system requirements are recommended:
- Memory
-
-
Machines with a minimum of 8 GB RAM for the Mainnet.
-
Machines with a minimum of 8 GB RAM for the Testnet.
-
- Storage
-
-
Machines with a minimum of 40 GB HDD[1].
-
Create a new user
To run and manage a Klayr Core node in the future, please create a separate klayr
user as described below:
The |
sudo adduser klayr
The above command will create a new user.
It is not necessarily required to set up a klayr
user, especially when you are running a local instance for development purposes.
However, if it is required then it is recommended to create the user using the MacOS GUI.
Git
Git is used for cloning and updating Klayr as displayed below:
Node.js
Node.js serves as the underlying engine for code execution.
It is recommended to use a Node version manager such as NVM. NVM is a bash script that enables the management of multiple active Node.js versions.
-
Install NVM by following the official instructions.
-
Install the latest LTS version of Node.js using NVM with the following command shown below:
nvm install 18
If NVM or other package managers are not required, it is possible to install the Node package globally as shown in the following commands below:
Ubuntu
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
MacOS
For MacOS, please execute the following command below:
brew install node@18
Open ports
Please ensure, that the necessary ports are open to run Klayr Core as intended.
For example, in case ufw is used on Ubuntu to manage the firewall settings, the respective ports can be opened as follows:
8778 and 7887 are the default ports.
If you configured custom ports in the node config file, adjust the examples to these specific ports.
|
ufw allow 7887
ufw allow 8778
PM2 (optional)
Install PM2 for managing the start and stop of the application process in the background as shown below:
npm install pm2 -g
Installation
This section details how to install Klayr Core from the source code. When completed, a functioning node on the Klayr network will exist.
Executing the following commands below will enable you to clone the repository, navigate into the klayr-core
root folder, check out the latest release tag, and install the dependencies.
git clone https://github.com/KlayrHQ/klayr-core.git
cd klayr-core
git checkout v4.1.5
Please check for the latest release in Klayr Core releases. |
yarn install --frozen-lockfile
yarn build
Set up the klayr-core
alias: Append the following line to your ~/.profile
file and run source ~/.profile
.
alias klayr-core=/home/klayr/klayr-core/bin/run
In the command above, please replace /home/klayr/klayr-core with the absolute path to your "klayr-core" directory.
To find the exact path on your system, change to your "klayr-core" directory and run the pwd command.
|
To test that Klayr Core is built and configured correctly, execute the following command below to connect to the network:
klayr-core start --network devnet
From another terminal, execute the following command:
klayr-core system node-info
If the process is running correctly, no errors are thrown in the logs.
Post-installation (optional)
Use pm2 to run Klayr Core in the background
It is recommended to use a process manager such as PM2 to run Klayr Core in the background.
Enable IPC & WS in the config
To make use of all the Klayr Core commands, enable IPC in the config.
"rpc": {
// Enable RPC communication over 'ipc' and 'ws'
"modes": ["ipc", "ws"]
// In case `modes` include `ws` then, the following port is used
"port": 7887,
// Change to 0.0.0.0 to connect from a remote server
"host": "127.0.0.1"
},
Alternatively, start Klayr Core with the flag --api-ipc
to enable IPC:
klayr-core start --api-ipc
Please note that specifying any of the --api-ipc , --api-ws , or --api-http flags in the klayr-core start command overrides the rpc.modes settings in the config.json .
|