问题
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
回答1:
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
来源:https://stackoverflow.com/questions/45600952/deploy-node-js-application-with-express-framework-on-production-mode