0

How to deploy node js application with express framework with production environment variable with pm2 and generate startup script for reboot with same production environment variable.

I have used this so far

pm2 start hello.js
pm2 startup systemd 
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup 
systemd -u sammy --hp /home/sammy

It starts the application on reboot but in development mode

Lakshay Jain
  • 446
  • 1
  • 3
  • 17

1 Answers1

0

To start a Node.js app in production mode, you'd need to set the NODE_ENV like so:

NODE_ENV=production # updates from 'development' to 'production'
pm2 start hello.js
pm2 startup systemd 
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup 
systemd -u sammy --hp /home/sammy
Akinjide
  • 2,723
  • 22
  • 28