Running and monitoring NodeJS apps with pm2 and Keymetrics

Few days ago I deployed to production first version of - small web app, written on Rails API + VueJS + NuxtJS.

After first deployment of Rails API with Mina, we need to start and monitor two frontend apps: MongoDB web client - adminMongo and VueJS app for our frontend part.

To run those scripts as a daemons, guys from Keymetrics created great tool called pm2. So, let’s try it!

First of all we need to install pm2 into our production environment:

sudo npm install -g pm2

Great! It was our first step :) So, next move about running our apps.

For example, starting our adminMongo app, is super easy:

pm2 start app.js

# After first run, script setup your free account in keymetrics website.

And our Vue + Nuxt application a little bit tricky:

pm2 start npm --name "coffeekzn_frontend" -- start

Great, now we can list our apps:

pm2 list


And monitor them:

pm2 monit


And the super feature! The startup subcommand generates and configures a startup script to launch PM2 and its managed processes on server boots:

pm2 startup systemd

Last step - let’s take a look into Keymetrics Dashboard:


Happy coding and monitoring ! :)