Deploy node js application with express framework on production mode

空扰寡人 提交于 2019-12-14 03:21:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!