使用生态系统配置文件在PM2上运行Express App时出现问题 [英] Problem running express app with pm2 using ecosystem config file
问题描述
当我使用 node
命令运行Node.js Express应用程序时,一切正常!使用 pm2服务器
./bin/www`时,我的pm2状态如下:
When I run my Node.js express app using node
command everything works fine!
When using pm2 server
./bin/www` my pm2 status is something like this:
在这种情况下,我的应用程序可以工作.另外,当我使用 pm2启动bin"./bin/www" -i 0
时,我的 pm2列表
显示:
And my app works in this situation. Also when I use pm2 start bin "./bin/www" -i 0
my pm2 list
shows:
我的应用仍然可以正常工作.但是使用以下配置文件:
And yet again my app works. But using following config file:
module.exports = {
apps: [{
name: 'cdn',
script: './bin/www',
instances: 0,
exec_mode: 'cluster',
watch: true,
env: {
NODE_ENV: 'production',
PORT: process.env.PORT || '5555',
}
}]
};
在指定端口上侦听时,该应用程序不起作用,并且不打印任何错误消息,并且我的pm2状态为:
the application while listening on the specified port does not work and prints no error messages and my pm2 status is:
我应该如何正确使用配置文件?
How should I use config file correctly?
推荐答案
也许您忘记了生态系统文件名中的 .config.js
.
Maybe you forgot .config.js
in your ecosystem filename.
I lost hours of my day looking for the exact same problem yours and a ignored line of pm2 docs alerts me what I forgot (a weird requirement).
请注意,使用Javascript配置文件要求文件名以.config.js结尾
Note that using a Javascript configuration file requires to end the file name with .config.js
这篇关于使用生态系统配置文件在PM2上运行Express App时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!