简体   繁体   English

pm2进程停止运行

[英]Pm2 process stops running

I have a node chat application that needs to keep running on my server (ubuntu with nginx). 我有一个节点聊天应用程序,需要继续在服务器上运行(使用nginx的ubuntu)。 The problem is that the application stops after a few hours or days. 问题是该应用程序在几个小时或几天后停止。 When I check on the server I see that my pm2 list is empty. 当我检查服务器时,我发现pm2列表为空。

The code I use to start my app: 我用来启动应用程序的代码:

pm2 start notification_server/index.js

It somehow looks as if pm2 is reset after a while. 似乎在一段时间后重置了pm2。 I also tried using forever, but then I run into the same problem. 我也尝试过永远使用,但后来遇到了同样的问题。 Is there some way to prevent the pm2 list from getting empty? 有什么方法可以防止pm2列表变空吗?

Did you try checking logs $ pm2 logs for you application? 您是否尝试过为应用程序检查日志$ pm2 logs

Most likely it will tell you why your application was terminated or maybe it just exited as it supposed to. 它很可能会告诉您您的应用程序为何被终止,或者只是按预期退出。 You could find something like that there: 您可以在那找到类似的东西:

PM2 | App [app] with id [0] and pid [11982], exited with code [1] via signal [SIGINT]

This can tell you what happened. 这可以告诉您发生了什么。 Without more details, it's hard to give you a better answer. 没有更多细节,很难为您提供更好的答案。

This is most likely an indication that your server is rebooting. 这很可能表明您的服务器正在重启。 When your server reboots, PM2 shuts down and deletes all Node instances from its "status" list. 服务器重新启动时,PM2关闭并从其“状态”列表中删除所有Node实例。

You can perform the following steps to make PM2 relaunch your Node programs start back up on reboot: 您可以执行以下步骤来使PM2重新启动,并在重新启动时启动Node程序:

  1. Run pm2 startup and follow the directions (you will have to perform a sudo command; PM will tell you exactly what to do). 运行pm2 startup并按照指示进行操作(您将必须执行sudo命令; PM会确切告诉您该怎么做)。
  2. Through pm2 start , get your Node processes up and running just like you like them. 通过pm2 start ,可以像您一样启动和运行Node进程。
  3. Run pm2 save to register the current state of things as what you want to see on system startup. 运行pm2 save将当前状态注册为您希望在系统启动时看到的状态。

Source: http://pm2.keymetrics.io/docs/usage/startup/ 来源: http//pm2.keymetrics.io/docs/usage/startup/

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

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