【发布时间】:2021-05-23 13:04:03
【问题描述】:
我尝试通过 PM2 在 Azure App Service (Linux) 上的 Next JS 应用程序上使用启动命令“pm2-runtime start Ecosystem.config.js”或“pm2 --no-daemon startecosystem.config”设置集群.js”。两个命令都失败。当我使用 pm2-runtime 时,传递给 NodeJS 脚本的当前工作目录变为:“wwwroot/ecosystem.config.js/.next”作为“目录参数”并且服务器失败。在第二个命令 pm2 --no-daemon 我收到信息未知或意外选项:--no-daemon。这两个命令都适用于“fork”模式。是否可以通过 nextjs app 为 azure app 服务设置集群模式?
ecosystem.config.code
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,
},
],
};*
--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. https://err.sh/vercel/next.js/production-start-no-build-id
0|next| at Server.readBuildId (/home/site/wwwroot/node_modules/next/next-server/server/next-server.ts:2044:15)
0|next| | at new Server (/home/site/wwwroot/node_modules/next/next-server/server/next-server.ts:199:25)
0|next| | at createServer (/home/site/wwwroot/node_modules/next/server/next.ts:41:10)
0|next| | at start (/home/site/wwwroot/node_modules/next/server/lib/start-server.ts:9:15)
0|next| | at exec (/home/site/wwwroot/node_modules/next/cli/next-start.ts:53:3)
0|next| | at /home/site/wwwroot/node_modules/next/bin/next.ts:113:19 code here
【问题讨论】:
标签: azure-web-app-service next.js pm2