PM2 commands
On this page, you’ll find the most relevant PM2 commands for running a source-based Lisk Service installation. For more details about PM2, see PM2 docs.
Moreover, we’ll also talk about the steps to reset a Lisk Service node.
Various PM2 commands
Start
Start Lisk Service.
pm2 start ecosystem.config.js
Response
[PM2] Applying action restartProcessId on app [lisk-service-gateway](ids: [ 0 ])
[PM2] Applying action restartProcessId on app [lisk-service-blockchain-app-registry](ids: [ 1 ])
[PM2] [lisk-service-gateway](0) ✓
[PM2] [lisk-service-blockchain-app-registry](1) ✓
[PM2] Applying action restartProcessId on app [lisk-service-blockchain-connector](ids: [ 2 ])
[PM2] [lisk-service-blockchain-connector](2) ✓
[PM2] Applying action restartProcessId on app [lisk-service-blockchain-indexer](ids: [ 3 ])
[PM2] [lisk-service-blockchain-indexer](3) ✓
[PM2] Applying action restartProcessId on app [lisk-service-blockchain-coordinator](ids: [ 4 ])
[PM2] [lisk-service-blockchain-coordinator](4) ✓
[PM2] Applying action restartProcessId on app [lisk-service-fee-estimator](ids: [ 5 ])
[PM2] [lisk-service-fee-estimator](5) ✓
[PM2] Applying action restartProcessId on app [lisk-service-transaction-statistics](ids: [ 6 ])
[PM2] [lisk-service-transaction-statistics](6) ✓
[PM2] Applying action restartProcessId on app [lisk-service-market](ids: [ 7 ])
[PM2] [lisk-service-market](7) ✓
[PM2] Applying action restartProcessId on app [lisk-service-export](ids: [ 8 ])
[PM2] [lisk-service-export](8) ✓
┌----------------------------------------------------------------------------------------------------------------------------------------------------------------------------┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├----------------------------------------------------------------------------------------------------------------------------------------------------------------------------┤
│ 1 │ lisk-service-blockchain-app-registry │ default │ 0.7.0-… │ fork │ 33328 │ 0s │ 16 │ online │ 0% │ 65.5mb │ XYZ │ disabled │
│ 2 │ lisk-service-blockchain-connector │ default │ 0.7.0-… │ fork │ 33331 │ 0s │ 0 │ online │ 0% │ 63.8mb │ XYZ │ disabled │
│ 4 │ lisk-service-blockchain-coordinator │ default │ 0.7.0-… │ fork │ 33341 │ 0s │ 0 │ online │ 0% │ 54.1mb │ XYZ │ disabled │
│ 3 │ lisk-service-blockchain-indexer │ default │ 0.7.0-… │ fork │ 33338 │ 0s │ 16 │ online │ 0% │ 54.3mb │ XYZ │ disabled │
│ 8 │ lisk-service-export │ default │ 0.7.0-… │ fork │ 33355 │ 0s │ 15 │ online │ 0% │ 14.1mb │ XYZ │ disabled │
│ 5 │ lisk-service-fee-estimator │ default │ 0.7.0-… │ fork │ 33346 │ 0s │ 15 │ online │ 0% │ 46.9mb │ XYZ │ disabled │
│ 0 │ lisk-service-gateway │ default │ 0.7.0-… │ fork │ 33326 │ 0s │ 15 │ online │ 0% │ 65.6mb │ XYZ │ disabled │
│ 7 │ lisk-service-market │ default │ 0.7.0-… │ fork │ 33351 │ 0s │ 15 │ online │ 0% │ 36.9mb │ XYZ │ disabled │
│ 6 │ lisk-service-transaction-statistics │ default │ 0.7.0-… │ fork │ 33348 │ 0s │ 15 │ online │ 0% │ 43.5mb │ XYZ │ disabled │
└----------------------------------------------------------------------------------------------------------------------------------------------------------------------------┘
List
View the status of different microservices of Lisk Service in the list of PM2 processes:
pm2 list
Response
┌----------------------------------------------------------------------------------------------------------------------------------------------------------------------------┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├----------------------------------------------------------------------------------------------------------------------------------------------------------------------------┤
│ 1 │ lisk-service-blockchain-app-registry │ default │ 0.7.0-… │ fork │ 33328 │ 0s │ 16 │ online │ 0% │ 65.5mb │ XYZ │ disabled │
│ 2 │ lisk-service-blockchain-connector │ default │ 0.7.0-… │ fork │ 33331 │ 0s │ 0 │ online │ 0% │ 63.8mb │ XYZ │ disabled │
│ 4 │ lisk-service-blockchain-coordinator │ default │ 0.7.0-… │ fork │ 33341 │ 0s │ 0 │ online │ 0% │ 54.1mb │ XYZ │ disabled │
│ 3 │ lisk-service-blockchain-indexer │ default │ 0.7.0-… │ fork │ 33338 │ 0s │ 16 │ online │ 0% │ 54.3mb │ XYZ │ disabled │
│ 8 │ lisk-service-export │ default │ 0.7.0-… │ fork │ 33355 │ 0s │ 15 │ online │ 0% │ 14.1mb │ XYZ │ disabled │
│ 5 │ lisk-service-fee-estimator │ default │ 0.7.0-… │ fork │ 33346 │ 0s │ 15 │ online │ 0% │ 46.9mb │ XYZ │ disabled │
│ 0 │ lisk-service-gateway │ default │ 0.7.0-… │ fork │ 33326 │ 0s │ 15 │ online │ 0% │ 65.6mb │ XYZ │ disabled │
│ 7 │ lisk-service-market │ default │ 0.7.0-… │ fork │ 33351 │ 0s │ 15 │ online │ 0% │ 36.9mb │ XYZ │ disabled │
│ 6 │ lisk-service-transaction-statistics │ default │ 0.7.0-… │ fork │ 33348 │ 0s │ 15 │ online │ 0% │ 43.5mb │ XYZ │ disabled │
└----------------------------------------------------------------------------------------------------------------------------------------------------------------------------┘
Logs
To check the logs for the different microservices of Lisk Service, use the command pm2 logs PROCESS_NAME
, where PROCESS_NAME
is the respective PM2-managed process that contains the logs you wish to view.
Alternatively, it is also possible to check the logs for a specific PM2 process based on its process ID.
For example, pm2 logs 0
can be used to check the Lisk Service Gateway logs.
The process ID of each PM2-managed process can be seen by executing the List command. |
For example, to see the logs for the Gateway microservice, execute the following command:
pm2 logs lisk-service-gateway
Response
0|lisk-ser | 2023-07-19 17:53:08 503: 2023-07-19T17:53:08.503 INFO [TRANSIT] Connecting to the transporter...
0|lisk-ser | 2023-07-19 17:53:08 504: 2023-07-19T17:53:08.503 INFO [TRANSPORTER] Setting Redis transporter
0|lisk-ser | 2023-07-19 17:53:08 510: 2023-07-19T17:53:08.510 INFO [TRANSPORTER] Redis-sub client is connected.
0|lisk-ser | 2023-07-19 17:53:08 510: 2023-07-19T17:53:08.510 INFO [TRANSPORTER] Setting Redis transporter
0|lisk-ser | 2023-07-19 17:53:08 512: 2023-07-19T17:53:08.512 INFO [TRANSPORTER] Redis-pub client is connected.
0|lisk-ser | 2023-07-19 17:53:09 016: 2023-07-19T17:53:09.016 INFO [TEMP_SERVICE_GATEWAY] Waiting for service(s) 'indexer, connector'...
0|lisk-ser | 2023-07-19 17:53:09 018: 2023-07-19T17:53:09.018 INFO [REGISTRY] '$node' service is registered.
0|lisk-ser | 2023-07-19 17:53:09 018: 2023-07-19T17:53:09.018 INFO [$NODE] Service '$node' started.
0|lisk-ser | 2023-07-19 17:53:10 225: 2023-07-19T17:53:10.223 INFO [REGISTRY] Node 'XYZ.local-74790' connected.
0|lisk-ser | 2023-07-19 17:53:10 274: 2023-07-19T17:53:10.274 INFO [REGISTRY] Node 'XYZ.local-74787' connected.
0|lisk-ser | 2023-07-19 17:53:10 325: 2023-07-19T17:53:10.325 INFO [REGISTRY] Node 'XYZ.local-74798' connected.
0|lisk-ser | 2023-07-19 17:53:10 346: 2023-07-19T17:53:10.345 INFO [REGISTRY] Node 'XYZ.local-74772' connected.
0|lisk-ser | 2023-07-19 17:53:10 415: 2023-07-19T17:53:10.414 INFO [REGISTRY] Node 'XYZ.local-74804' connected.
0|lisk-ser | 2023-07-19 17:53:10 485: 2023-07-19T17:53:10.484 INFO [REGISTRY] Node 'XYZ.local-74795' connected.
0|lisk-ser | 2023-07-19 17:53:10 676: 2023-07-19T17:53:10.675 INFO [REGISTRY] Node 'XYZ.local-74779' connected.
Flush
Remove all the logs of the PM2-managed processes defined in the specified config file.
pm2 flush ecosystem.config.js
Response
[PM2] Logs flushed
Stop
Stop PM2 managed Lisk Service instance.
pm2 stop ecosystem.config.js
Response
[PM2] [lisk-service-blockchain-app-registry](1) ✓
[PM2] [lisk-service-gateway](0) ✓
[PM2] [lisk-service-blockchain-indexer](3) ✓
[PM2] [lisk-service-blockchain-connector](2) ✓
[PM2] [lisk-service-blockchain-coordinator](4) ✓
[PM2] [lisk-service-fee-estimator](5) ✓
[PM2] [lisk-service-transaction-statistics](6) ✓
[PM2] [lisk-service-market](7) ✓
[PM2] [lisk-service-export](8) ✓
┌------------------------------------------------------------------------------------------------------------------------------------------------------------------------┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├------------------------------------------------------------------------------------------------------------------------------------------------------------------------┤
│ 1 │ lisk-service-blockchain-app-registry │ default │ 0.7.0-… │ fork │ 0 │ 0 │ 32 │ stopped │ 0% │ 0b │ XYZ │ disabled │
│ 2 │ lisk-service-blockchain-connector │ default │ 0.7.0-… │ fork │ 0 │ 0 │ 0 │ stopped │ 0% │ 0b │ XYZ │ disabled │
│ 4 │ lisk-service-blockchain-coordinator │ default │ 0.7.0-… │ fork │ 0 │ 0 │ 0 │ stopped │ 0% │ 0b │ XYZ │ disabled │
│ 3 │ lisk-service-blockchain-indexer │ default │ 0.7.0-… │ fork │ 0 │ 0 │ 32 │ stopped │ 0% │ 0b │ XYZ │ disabled │
│ 8 │ lisk-service-export │ default │ 0.7.0-… │ fork │ 0 │ 0 │ 30 │ stopped │ 0% │ 0b │ XYZ │ disabled │
│ 5 │ lisk-service-fee-estimator │ default │ 0.7.0-… │ fork │ 0 │ 0 │ 30 │ stopped │ 0% │ 0b │ XYZ │ disabled │
│ 0 │ lisk-service-gateway │ default │ 0.7.0-… │ fork │ 0 │ 0 │ 30 │ stopped │ 0% │ 0b │ XYZ │ disabled │
│ 7 │ lisk-service-market │ default │ 0.7.0-… │ fork │ 0 │ 0 │ 30 │ stopped │ 0% │ 0b │ XYZ │ disabled │
│ 6 │ lisk-service-transaction-statistics │ default │ 0.7.0-… │ fork │ 0 │ 0 │ 30 │ stopped │ 0% │ 0b │ XYZ │ disabled │
└------------------------------------------------------------------------------------------------------------------------------------------------------------------------┘
Restart
Restart Lisk Service via PM2.
pm2 restart ecosystem.config.js
Response
[PM2] Applying action restartProcessId on app [lisk-service-gateway](ids: [ 0 ])
[PM2] Applying action restartProcessId on app [lisk-service-blockchain-app-registry](ids: [ 1 ])
[PM2] [lisk-service-gateway](0) ✓
[PM2] [lisk-service-blockchain-app-registry](1) ✓
[PM2] Applying action restartProcessId on app [lisk-service-blockchain-connector](ids: [ 2 ])
[PM2] Applying action restartProcessId on app [lisk-service-blockchain-indexer](ids: [ 3 ])
[PM2] [lisk-service-blockchain-indexer](3) ✓
[PM2] Applying action restartProcessId on app [lisk-service-blockchain-coordinator](ids: [ 4 ])
[PM2] [lisk-service-blockchain-connector](2) ✓
[PM2] Applying action restartProcessId on app [lisk-service-fee-estimator](ids: [ 5 ])
[PM2] [lisk-service-blockchain-coordinator](4) ✓
[PM2] [lisk-service-fee-estimator](5) ✓
[PM2] Applying action restartProcessId on app [lisk-service-transaction-statistics](ids: [ 6 ])
[PM2] Applying action restartProcessId on app [lisk-service-market](ids: [ 7 ])
[PM2] [lisk-service-transaction-statistics](6) ✓
[PM2] [lisk-service-market](7) ✓
[PM2] Applying action restartProcessId on app [lisk-service-export](ids: [ 8 ])
[PM2] [lisk-service-export](8) ✓
┌----------------------------------------------------------------------------------------------------------------------------------------------------------------------------┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├----------------------------------------------------------------------------------------------------------------------------------------------------------------------------┤
│ 1 │ lisk-service-blockchain-app-registry │ default │ 0.7.0-… │ fork │ 33328 │ 0s │ 16 │ online │ 0% │ 65.5mb │ XYZ │ disabled │
│ 2 │ lisk-service-blockchain-connector │ default │ 0.7.0-… │ fork │ 33331 │ 0s │ 0 │ online │ 0% │ 63.8mb │ XYZ │ disabled │
│ 4 │ lisk-service-blockchain-coordinator │ default │ 0.7.0-… │ fork │ 33341 │ 0s │ 0 │ online │ 0% │ 54.1mb │ XYZ │ disabled │
│ 3 │ lisk-service-blockchain-indexer │ default │ 0.7.0-… │ fork │ 33338 │ 0s │ 16 │ online │ 0% │ 54.3mb │ XYZ │ disabled │
│ 8 │ lisk-service-export │ default │ 0.7.0-… │ fork │ 33355 │ 0s │ 15 │ online │ 0% │ 14.1mb │ XYZ │ disabled │
│ 5 │ lisk-service-fee-estimator │ default │ 0.7.0-… │ fork │ 33346 │ 0s │ 15 │ online │ 0% │ 46.9mb │ XYZ │ disabled │
│ 0 │ lisk-service-gateway │ default │ 0.7.0-… │ fork │ 33326 │ 0s │ 15 │ online │ 0% │ 65.6mb │ XYZ │ disabled │
│ 7 │ lisk-service-market │ default │ 0.7.0-… │ fork │ 33351 │ 0s │ 15 │ online │ 0% │ 36.9mb │ XYZ │ disabled │
│ 6 │ lisk-service-transaction-statistics │ default │ 0.7.0-… │ fork │ 33348 │ 0s │ 15 │ online │ 0% │ 43.5mb │ XYZ │ disabled │
└----------------------------------------------------------------------------------------------------------------------------------------------------------------------------┘
Delete
Remove all processes from the PM2 list.
pm2 delete ecosystem.config.js
Response
[PM2] [lisk-service-gateway](0) ✓
[PM2] [lisk-service-blockchain-app-registry](1) ✓
[PM2] [lisk-service-blockchain-indexer](3) ✓
[PM2] [lisk-service-blockchain-connector](2) ✓
[PM2] [lisk-service-blockchain-coordinator](4) ✓
[PM2] [lisk-service-fee-estimator](5) ✓
[PM2] [lisk-service-transaction-statistics](6) ✓
[PM2] [lisk-service-market](7) ✓
[PM2] [lisk-service-export](8) ✓
┌----------------------------------------------------------------------------------------------------------------------------------------------┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
└----------------------------------------------------------------------------------------------------------------------------------------------┘
[PM2][WARN] Current process list is not synchronized with saved list. App lisk-service-gateway lisk-service-blockchain-app-registry lisk-service-blockchain-connector lisk-service-blockchain-indexer lisk-service-blockchain-coordinator lisk-service-fee-estimator lisk-service-transaction-statistics lisk-service-market lisk-service-export differs. Type 'pm2 save' to synchronize.
Resetting Lisk Service
Clean all run-time files with dependencies
make clean-local
Response
rm -rf node_modules
cd ./framework && rm -rf node_modules
cd ./services/blockchain-app-registry && rm -rf node_modules
cd ./services/blockchain-connector && rm -rf node_modules
cd ./services/blockchain-coordinator && rm -rf node_modules
cd ./services/blockchain-indexer && rm -rf node_modules
cd ./services/transaction-statistics && rm -rf node_modules
cd ./services/fee-estimator && rm -rf node_modules
cd ./services/market && rm -rf node_modules
cd ./services/gateway && rm -rf node_modules
cd ./services/export && rm -rf node_modules
cd ./services/template && rm -rf node_modules
cd ./tests && rm -rf node_modules
Reset the Lisk Service database
To reset the database of Lisk Service, drop the respective MySQL and Redis databases.
Drop the MySQL database
-
Stop Lisk Service
yarn stop
-
Login to MySQL with the
lisk
user.mysql -u lisk -ppassword
-
Drop the database.
mysql> drop database lisk;
-
Create a fresh database.
mysql> create database lisk;
-
Quit MySQL.
mysql> quit;
The process to re-index all the data commences after Lisk Service starts again following a database reset. The process can be rather time-consuming and could take several hours, depending on the length of the chain. |
Flush Redis DB
Reset the databases for Redis after dropping the MySQL database:
redis-cli flushall
The
For more information, check the Redis documentation: FLUSHALL. To flush only a particular database in Redis, execute the following command instead:
|
You can start Lisk Service again with the Start command.