前叉:无法分配内存-运行带有PM2的NodeJS的Ubuntu NGINX

时间:2019-11-11 12:49:37

标签: node.js pm2

我在DigitalOcean上有一个运行NGINX的Ubuntu Droplet,它具有两个NodeJS应用程序的反向代理,这两个NodeJS应用程序在不同的端口上运行,并由PM2管理。

我看到的问题是:

应用程序使用puppeteer进行一些屏幕截图,然后将图像卸载到云服务。但是我认为完成图像处理后,Node内存不足,最终看到此消息:

@override
  Widget build(BuildContext context) {
    if(todayTasks == null) {
      update();
      return Center(
        child: CircularProgressIndicator(),
      );
    } //make a query if the list has not yet been initialized
    return ListView(
      physics: const AlwaysScrollableScrollPhysics(),
      children: <Widget>[
        //other widgets
        pendingList(Task.filterByDone(false, todayTasks)),
      ],
    );
  }

然后液滴运行缓慢并经常崩溃。

我具有用于启动PM2服务的以下命令:

-bash: fork: Cannot allocate memory

我也尝试了以下方法,但这没有用。如果更改命令顺序,我只会得到pm2 start npm --name "Production" -- start -max_old_space_size'`:

error: unknown option

我正在运行节点v12.13.0和Ubuntu 18.04.3 LTS

请问有人可以如何解决这个问题,或者至少可以调试,我可以提供更多细节吗?

1 个答案:

答案 0 :(得分:1)

使用node-args

—-node-args="max-old-space-size=6144"