Source code commands
This section covers how to manage a Source code installation of Lisk Core.
Basic commands
Status
Check the status of the Lisk Core node by executing the following command below:
pm2 status lisk
Delete
Remove Lisk Core process from the pm2 list by executing the following command below:
pm2 delete lisk
Add
In case this was not completed during the installation process, add your Lisk Core process to pm2 under the name lisk
by executing the following command below:
pm2 start --name lisk dist/index.js -- --network [network]
It is possible to choose the devnet
(default), or betanet
for the [network]
option.
Utility scripts
There are some command line scripts available that will assist the Lisk user, by performing certain helpful and convenient operations.
All scripts are located under ./scripts/
directory and can be executed directly by node scripts/<file_name>
.
Generate config
This script shown below will help to generate a unified version of the configuration file for any network:
Usage: node scripts/generate_config.js [options]
Options:
-h, --help output usage information
-V, --version output the version number
-c, --config [config] custom config file
-n, --network [network] specify the network or use LISK_NETWORK
Argument network
is required, and it may be either devnet
, betanet
or any other network folder available under ./config
directory.
Update config
This next script is designed to keep track of all changes introduced in Lisk over time in different versions. If you have one config file existing in any specific version, and you wish to make it compatible with other versions of Lisk Core, then execute the update config script shown below:
Usage: node scripts/update_config.js [options] <input_file> <from_version> [to_version]
Options:
-h, --help output usage information
-V, --version output the version number
-n, --network [network] specify the network or use LISK_NETWORK
-o, --output [output] output file path
As can be seen from the usage guide, input_file
and from_version
are required.
If you skip to_version
argument changes in config.json
will be applied up to the latest version of Lisk Core.
If you do not specify --output
path the final config.json
will be printed to stdout.
If you do not specify --network
argument, it will have to be loaded from LISK_NETWORK
env variable.
Creating snapshots
For creating snapshots in the most convenient manner, it is recommended to use the Lisk Core application.
Execute the script |
To create a snapshot manually, perform the following steps listed below:
Example: Creating a snapshot for Lisk Betanet.
The template database to be used should be the actual database defined in the |
pm2 stop lisk (1)
createdb --template="lisk_beta" lisk_snapshot (2)
pm2 start lisk (3)
psql --dbname=lisk_snapshot --command='TRUNCATE peers, mem_accounts2u_delegates, mem_accounts2u_multisignatures;' (4)
psql --dbname=lisk_snapshot --tuples-only --command='SELECT height FROM blocks ORDER BY height DESC LIMIT 1;' | xargs (5)
pg_dump --no-owner lisk_snapshot |gzip -9 > snapshot-lisk_betanet-<current-block-height>.gz (6)
dropdb lisk_snapshot (7)
1 | Stops the Lisk Core node. |
2 | Copies the Lisk Betanet database to a new database lisk_snapshot .
During this process, no open connections are allowed to lisk_beta or it will fail. |
3 | Restarts the Lisk Core node again. |
4 | Removes the redundant data. |
5 | Executes this SQL query to acquire the last block height of the snapshot. |
6 | Dumps the database and compresses it. Replaces the <current-block-height> with the height that was returned by the SQL query above. |
7 | Deletes the snapshot database. |
Rebuild from a snapshot
In certain scenarios it is recommended to restore the blockchain from a snapshot.
The command lines shown below will perform this process.
The URL can be substituted for another blockchain.db.gz
snapshot file if so desired.
pm2 stop lisk (1)
dropdb lisk_beta (2)
wget https://downloads.lisk.io/lisk/beta/blockchain.db.gz (3)
createdb lisk_beta (4)
gunzip -fcq blockchain.db.gz | psql -d lisk_beta (5)
pm2 start lisk (6)
1 | Stops the Lisk Core node. |
2 | Deletes the Lisk Betanet database. |
3 | Downloads the Lisk snapshot. |
4 | Creates a fresh Lisk Betanet database. |
5 | Imports the downloaded snapshot into the new database. |
6 | Restarts the Lisk Core node again. |