Starting the node from source
- Introduction
- Setting up the environment
- Downloading and building the node
- Starting the node
- How to stop the node?
- How to check, if my node works?
Introduction
TP-Node is the main module of The Power Ecosystem. In this manual, you'll learn how to start a node from the source code on Linux.
Setting up the environment
Before you start your TP-Node, you need to set up the environment.
Install Erlang
You can install Erlang either using the package manager, or using kerl.
Install Erlang using the package manager
If you use the recommended Ubuntu version (22.04.1), you can install Erlang using the package manager. To do this, run the following command:
apt install cmake clang gcc git curl libssl-dev build-essential automake autoconf libncurses5-dev elixir erlang
If you use other version of Ubuntu (20.04, for instance), refer to the section below to install Erlang using kerl.
Install Erlang using kerl
To install Erlang using kerl:
-
Download the
kerlscriptcurl -O https://raw.githubusercontent.com/kerl/kerl/master/kerlNote
If you already have Erlang installed on your machine, we strongly recommend deleting it before the new installation, using the following command:
apt purge erlang* -
Change script mode to executable by using the following command:
chmod a+x kerl -
Go to the
/optdirectory:cd /opt -
Create a new directory in
/opt. You can choose any name for this directory. Noteworthy is that the name should be descriptive for you:mkdir erlang -
Go back to the root directory:
cd ~ -
Update the list of Erlang releases using the following command:
./kerl update releases -
Build the release 24.3 using the following command:
./kerl build 24.3
After installation is complete, you will see the following message in the console:
Erlang/OTP 24.3 (24.3) has been successfully built
-
Install Erlang using the following command:
./kerl install 24.3 /opt/erlang -
Run the following command to activate the Erlang installation:
source /opt/erlang/activate
Downloading and building the node
After setting up the working environment, you can download and build the node:
Note
Choose a project folder to clone your project into. Use this folder to build the node.
-
Download the node sources from Github into your working directory (
your_node, for instance), using the following command:git clone https://github.com/thepower/tpnode.git -b e24 -
Delete the previous builds (if present) in
/tpnodeby running the following command:rm -rf _build/default/* -
Compile the node source by running the following command:
./rebar3 compile -
Build the release by running the following command:
./rebar3 release -
Copy the node directory from
_build/default/rel/thepowerto/optby running the following command:cp -r _build/default/rel/thepower /opt
Now you can start the node.
Starting the node
Start the node using systemd. To do this:
-
Create a file
tpnode.serviceunder/etc/systemd/systemdirectory. -
The file must contain the following:
[Unit]
Description=tpnode service
Requires=network.target
After=network.target
[Service]
Type=forking
ExecStart=/opt/thepower/bin/thepower start
ExecStop=/opt/thepower/bin/thepower stop
User=root
Group=root
Restart=on-failure
[Install]
WantedBy=multi-user.target -
Run the following command to rerun all generators , reload all unit files, and recreate the entire dependency tree. While the daemon is being reloaded, all sockets systemd listens on behalf of user configuration will stay accessible:
systemctl daemon-reload -
Run the following command to enable the service after reboot:
systemctl enable tpnode.service -
Start the node using the following command:
systemctl start tpnode.service
How to stop the node?
To stop the node, run:
systemctl stop tpnode.service
How to check, if my node works?
To check, if your node works, run:
curl http://your_node.example.com:1080/api/node/status | jq
where:
your_node.example.com— your node address;1080— port, that your node uses forapi.
Replace the example parameters with the ones you need.