【发布时间】:2020-10-29 10:58:22
【问题描述】:
我有一个在 AWS Elastic Beanstalk 中构建的 NodeJs 环境。我正在使用 pm2 监控上传到环境的 2 个不同的 NodeJS 应用程序。关键是我需要确保local 应用程序在gateway 应用程序启动之前启动。我正在使用npm-run-all 同步以特定顺序启动应用程序。
这是我的 package.json:
"start": "npm-run-all -s start:local start:gateway",
"start:local": "pm2 start ./ecosystem.config.js --only local-service --env production",
"start:gateway": "pm2 start ./ecosystem.config.js --only gateway-service --env production",
这是我的生态系统.config 文件:
module.exports =
{
apps:
[
{
name: 'local-service',
script: './dist/services/local.js',
watch: false,
interpreter: 'node',
interpreter_args: '--require ts-node/register --require tsconfig-paths/register',
autorestart: false
},
{
name: 'gateway-service',
script: './dist/server.js',
watch: false,
interpreter: 'node',
interpreter_args: '--require ts-node/register --require tsconfig-paths/register',
wait_ready: true,
listen_timeout: 5000,
autorestart: false
}
]
};
elastic beanstalk 日志显示 package.json 中的start 不断被调用。我已将每个应用程序配置为不重启,但似乎还有其他原因导致持续重启发生。我在尝试访问网关服务本身时收到 502 Bad Gateway 错误。
【问题讨论】:
-
你能提供一个演示吗?
标签: node.js amazon-elastic-beanstalk pm2