Process management with pm2

It is recommended to set up additional process management with the new Lisk Core CLI. Any process management tool can be used to manage the Lisk Core node. We recommend using PM2 to manage the instance.

Setup

Install pm2 globally:

npm i -g pm2

PM2 config

Create a pm2 config, for example as shown below:

pm2.conf.json
{
  "name": "lisk-core",
  "script": "lisk-core start --overwrite-config",
  "env": {
    "LISK_NETWORK": "testnet",
    "LISK_CONFIG_FILE": "/home/lisk/lisk-core/custom-config.json"
  }
}
All available options for scripts and env can be found in lisk-core start --help.

To add the process to PM2 and start it directly, execute the following command:

pm2 start pm2.conf.json

Show status

View the status of Lisk Core in the list of running PM2 processes:

pm2 ls
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name               │ mode     │ ↺    │ status    │ cpu      │ memory   │
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
│ 0  │ lisk-core          │ fork     │ 0    │ online    │ 0%       │ 3.1mb    │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘

Starting Lisk Core with PM2

Execute the following command to start Lisk Core:

pm2 start lisk-core

Saving the app list to be restored at reboot

Once Lisk Core is started, it is convenient to save the app list so it will respawn after rebooting:

pm2 save

For more information, please refer to https://pm2.keymetrics.io/docs/usage/pm2-doc-single-page/

Stopping Lisk Core

To stop Lisk Core, simply stop the PM2 Lisk Core process:

pm2 stop lisk-core

Refreshing / restarting Lisk Core

To refresh Lisk Core after changing the configuration, delete the existing lisk-core process with pm2, and then use the pm2 config file to restart the process.

pm2 delete lisk-core
pm2 start pm2.conf.json