0

我有一些带有少量 RAM 的 DigitalOcean 液滴,但我应该在那里托管很多 pm2 进程(更准确地说,集群模式下 9-8 个(提供-i 0)和 fork 模式下 1 个)。这些进程是 NodeJS Express 服务器,为 React.js 项目进行服务器端渲染。

因此,正如预期的那样,有时 pm2 崩溃是因为没有足够的 RAM,并且在它崩溃之后它显然不会恢复所有进程,尽管启用了启动守护程序。

我知道,启动守护进程只在系统启动时起作用,所以现在每次 pm2 崩溃时,我都应该手动转到 droplet 并在其上重新启动系统。

是否有任何解决方法可以自动执行此过程?或者,也许存在一些在 pm2 启动时工作的 pm2 守护进程?

感谢任何帮助!
提前致谢!


更新

这是最后的崩溃日志(与手动崩溃相关的部分):

<--- Last few GCs --->

[11194:0x3184710] 38854201 ms: Scavenge 24.7 (28.2) -> 23.8 (28.2) MB, 0.5 / 0.0 ms  allocation failure
[11194:0x3184710] 38888980 ms: Scavenge 24.8 (28.2) -> 23.9 (28.7) MB, 0.7 / 0.0 ms  allocation failure
[11194:0x3184710] 39006864 ms: Scavenge 24.8 (28.7) -> 23.9 (28.7) MB, 0.7 / 0.0 ms  allocation failure
[11194:0x3184710] 39131478 ms: Scavenge 24.8 (28.7) -> 23.9 (28.7) MB, 0.4 / 0.0 ms  allocation failure


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0xa90e93a5879 <JSObject>
    0: builtin exit frame: parse(this=0xa90e93890a9 <Object map = 0x188eb7f82ba1>,0x33a45597fe41 <String[338]: {"type":"axm:monitor","data":{"Loop delay":{"value":"0.81ms","ag$

FATAL ERROR: Committing semi space failed. Allocation failed - process out of memory
1: node::Abort() [node /home/<private path>/frontend/dist-server/server.bundle.js]
2: 0x8c20ec [node /home/<private path>/frontend/dist-server/server.bundle.js]
3: v8::Utils::ReportOOMFailure(char const*, bool) [node /home/<private path>/frontend/dist-server/server.bundle.js]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node /home/<private path>/frontend/dist-server/server.bundle.js]
5: v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node /home/<private path>/frontend/dist-server/server.bundle$
6: v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node /home/<private path>/fronte$
7: v8::internal::Factory::NewJSObject(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::PretenureFlag) [node /home/<private path>/frontend/dist-server$
8: v8::internal::JsonParser<true>::ParseJsonObject() [node /home/<private path>/frontend/dist-server/server.bundle.js]
9: v8::internal::JsonParser<true>::ParseJsonValue() [node /home/<private path>/frontend/dist-server/server.bundle.js]
10: v8::internal::JsonParser<true>::ParseJson() [node /home/<private path>/frontend/dist-server/server.bundle.js]
11: v8::internal::Builtin_JsonParse(int, v8::internal::Object**, v8::internal::Isolate*) [node /home/<private path>/frontend/dist-server/server.bundle.js]
12: 0x1d7ee3e8697d
4

1 回答 1

1

将 PM2 连接到PM2+,以便将 PM2 连接到 PM2+ 的代理将充当第二个看门狗。如果主 PM2 崩溃,PM2+ 代理将使用之前的进程列表重新生成 PM2

于 2018-12-17T13:42:52.483 回答