I had nodejs app. Run via pm2 and nginx server.
But now I need a change from localhost:8082 server to api.example.com (subdomain).
I did some manipulations and now it is totally broke.
So, I started from the beginning.
I have a folder with nodejs code. I have env variables so I created an ecosystem by pm2 ecosystem
ecosystem:
module.exports = {
apps : [{
script: 'app.js',
watch: '.',
env: {
"PORT": 3000,
"NODE_ENV": "development"
},
env_production: {
"PORT": 81,
"NODE_ENV": "production",
}
}],
deploy : {
production : {
user : 'SSH_USERNAME',
host : 'SSH_HOSTMACHINE',
ref : 'origin/master',
repo : 'GIT_REPOSITORY',
path : 'DESTINATION_PATH',
'pre-deploy-local': '',
'post-deploy' : 'npm install && pm2 reload ecosystem.config.js --env production',
'pre-setup': ''
}
}
};
Then I run pm2 start ecosystem.config.js --env production
pm2 logs:
PM2 | App [app:0] exited with code [1] via signal [SIGINT]
PM2 | App [app:0] starting in -fork mode-
PM2 | App [app:0] online
0|app | WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names.
0|app | WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
0|app | Error: listen EADDRINUSE: address already in use :::80
0|app | at Server.setupListenHandle [as _listen2] (net.js:1313:16)
0|app | at listenInCluster (net.js:1361:12)
0|app | at Server.listen (net.js:1447:7)
0|app | at Function.listen (/var/www/backend/node_modules/express/lib/application.js:618:24)
0|app | at Object.<anonymous> (/var/www/backend/app.js:109:5)
0|app | at Module._compile (internal/modules/cjs/loader.js:1137:30)
0|app | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
0|app | at Module.load (internal/modules/cjs/loader.js:985:32)
0|app | at Function.Module._load (internal/modules/cjs/loader.js:878:14)
0|app | at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:32:23)
0|app | at Module._compile (internal/modules/cjs/loader.js:1137:30)
0|app | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
0|app | at Module.load (internal/modules/cjs/loader.js:985:32)
0|app | at Function.Module._load (internal/modules/cjs/loader.js:878:14)
0|app | at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
0|app | at internal/main/run_main_module.js:17:47 {
0|app | code: 'EADDRINUSE',
0|app | errno: 'EADDRINUSE',
0|app | syscall: 'listen',
0|app | address: '::',
0|app | port: 80
0|app | }
PM2 | App [app:0] exited with code [1] via signal [SIGINT]
PM2 | App [app:0] starting in -fork mode-
PM2 | App [app:0] online
So, I see it is trying to start on 80 port But I need it start on subdomain: api.example.com
I'm totally confused