I have a NodeJs environment built in AWS Elastic Beanstalk. I'm using pm2 to monitor 2 different NodeJS apps uploaded to environment. The kicker is I need to make sure the local app is started before the gateway app starts. I'm using npm-run-all synchronously to start apps in a specific order.
Here's my 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",
Here's my ecosystem.config file:
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
}
]
};
The elastic beanstalk log is indicating start in package.json is continuously being called. I've configured each app to not restart, but there seems to be something else causing the continuous restart to happen. I'm getting 502 Bad Gateway error when trying to access the gateway-service itself.