PM2 is a production process manager for node applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.
As we will see belowm Edge Microgateway, been a node app can benefit greatly from using this tool,
Find below the steps required to use PM2 with edgemicro:
-
Start edgemicro using the following command:
$ pm2 start edgemicro -- start -o <org> -e <env> -k <key> -s <secret> -
Check that edgemicro started properly having a look at the logs:
$ pm2 logs edgemicro<br> -
You can also have more details of the process running (pid, uptime, cpu usage, memory usage,…) with this other command:
$ pm2 list -
Get the automatically-configured startup script for your machine you need to typing this command:
$ pm2 startupIt automaticallly detects the available init system, but you can specify it yourself to (eg: pm2 startup systemd). You can also use option -u to specify the user and --hp to specify the home directory.
-
Once the scripts are generated run the following command to keep a list of the processes runing, so they will be started at boot time.
$ pm2 save -
If you want to actively monitor how edgemicro is performing you just nee to run:
$ pm2 monit -
In case you would like to have a Keymetrics dashboard, you can just go ahead and sign in for an account there, create a bucket and run the following command with the provided keys:
$ pm2 link <secret-key> <public-key>
Give it a try and let me know how it goes.