简体   繁体   English

无法使用PM2永久运行应用程序

[英]Cannot run application forever using PM2

When I am running the application using npm start I can able to run the application without any error. 当我使用运行应用程序NPM开始我能够没有任何错误运行应用程序。

I have installed pm2 to run node from now on. 我已经安装了pm2从现在开始运行节点。

I am using the command PM2 start npm start: 我正在使用命令PM2 start npm start:

then I am using PM2 logs npm command I am able to see the application running in the terminal: 然后我正在使用PM2 logs npm命令,我可以看到终端中正在运行的应用程序: But when I'm running the browser nothing is running. 但是,当我运行的浏览器没有运行。

Nothing is also running when I'm running the browser. 当我运行浏览器时,什么也没有运行。

Your npm start will most likely be a command with the node prefix, to run pm2 on a node project you'll have to NODE_ENV=<insert env> pm2 start node server.js and for react you'll have to pack/build your project and do pm2 start http-server -p <insert port> . 您的npm start很可能是带有节点前缀的命令,要在节点项目上运行NODE_ENV=<insert env> pm2 start node server.js您必须NODE_ENV=<insert env> pm2 start node server.js ,为了进行响应,您必须打包/构建您的项目并执行pm2 start http-server -p <insert port>

Other ways off running this forever is through nginx etc. 永远运行此方法的其他方法是通过nginx等。

Hope this helps :-) 希望这可以帮助 :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM