小编And*_*zej的帖子

Azure应用程序服务(Linux),NEXT JS应用程序,PM2无法设置集群模式

我尝试使用启动命令“pm2-runtime start Ecosystem.config.js”或“pm2 --no-daemon start Ecosystem.config.js”在Azure App Service(Linux)上的Next JS应用程序上通过PM2设置集群。两个命令都失败。当我使用 pm2-runtime 时,传递给 NodeJS 脚本的当前工作目录变为:“wwwroot/ecosystem.config.js/.next”作为“目录参数”,并且服务器失败。在第二个命令 pm2 --no-daemon 中,我收到信息未知或意外选项:--no-daemon。这两个命令都适用于“fork”模式。是否可以使用 nextjs 应用程序为 azure 应用程序服务设置集群模式?

生态系统配置代码

module.exports = {
    apps: [
        {
            name: 'next',
            script: './node_modules/next/dist/bin/next',
            args: 'start -p ' + (process.env.PORT || 3000), 
            instances: 2,
            exec_mode: 'cluster',
            watch: false,
            autorestart: true,
        },
    ],
};*
Run Code Online (Sandbox Code Playgroud)

--no-daemon 的错误

在此输入图像描述

Error for pm2-runtime
 Error: Could not find a production build in the '/home/site/wwwroot/ecosystem.config.js/.next' directory. Try building your app with 'next build' before starting the production se
rver. …
Run Code Online (Sandbox Code Playgroud)

pm2 azure-web-app-service next.js

1
推荐指数
1
解决办法
1331
查看次数

标签 统计

azure-web-app-service ×1

next.js ×1

pm2 ×1