I'm attempting to run two NodeJS applications on a single Linux Azure App Service. I start the PM2 with the ecosystem configuration shown below.
App1's domain name is app1.example.com.
App2's domain name is app2.example.com.
I see that APP1 is working properly, but APP2 is not. When I swap the configuration (APP2, APP1 in ecosystem.config.js), APP2 works but not APP1. As a result, I can only run one app.
When I attempt to debug APP2, I discover that the request app2.example.com is not reaching the application.
What is wrong with this approach, and can you recommend a better solution?
ecosystem.config.js
module.exports = {
apps: [
{
script: './app1/index.js',
name: 'app1',
watch: true,
instances: '1', // To set 0/max for spread the app across all CPUs
env: {
"NODE_ENV": "production",
},
},
{
script: './app2/index.js',
name: 'app2',
watch: true,
instances: '1', // To set 0/max for spread the app across all CPUs
env: {
"NODE_ENV": "production",
},
}
]
};
Check the below steps to run the NodeJS applications with PM2 in a single Azure App service.
Create a new Folder and within it create two separate
Node JSApplications.Follow this MSDoc to create Node JS Application.
Make sure both the Applications have
package.jsonfiles.VSCode.OR
You can run the PM2 globally on the applications root directory.
Start both the Applications using
PM2as mentioned in theazureossd.Node.Deployment Center, deploy the code usingFTPorGit.As you are using
ecosystem configurationadd pm2 startecosystem.config.jsin the startup command.Make sure your
ecosystem.config.jsis deployed in the Application root directory.If you have not configured the custom domains then, access your app's using the below URL`s.
AFAIK, the problem can be with configuration of the custom domains. Make sure you have custom domains configured correctly.
In
ecosystem.config.js, add the PORT No. below theNODE_ENV.