Teaching Research and Publishings Speaking Engagements Professional Development About Me

Notice: Undefined variable: connect in /var/www/codeadam.ca/includes/header.php on line 20

Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /var/www/codeadam.ca/includes/header.php on line 20

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /var/www/codeadam.ca/includes/header.php on line 22

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in /var/www/codeadam.ca/includes/header.php on line 24

Server Setup Documents


Installing and Configuring PM2

Installing PM2

Install PM2 using the SSH tool from Google Cloud.

Use this command:

sudo npm install -g pm2

Configure PM2

Locate the app.js file and start it using PM2:

cd /var/www/apps/index
pm2 start app.js --name "index"

If you then run this commandit will list the active NodeJS processes:

pm2 list

We then need to tell PM2 to start app.js in startup:

pm2 startup systemd

This command will create some output and provide a command that needs to be run. Copy and paste this command and push enter. It will look something like this:

sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u googleuser --hp /home/googleuser

You will need the following command to restart your NodeJS applications when developing:

pm2 restart index