Reputation: 2396
I just use eb deploy
and also tried upload with zip, the elatic beanstalk environment show "degraded".
The log when I click in to see is
Overall
Degraded
Impaired services on all instances.
Severe
Following services are not running: web.
My app.js file:
const express = require('express');
const app = express();
app.listen(3000, () => {
console.log("Sever console log.")
});
package.json content
{
"name": "project_api",
"version": "1.0.0",
"engines": {
"node": "12.18.3"
},
"description": "the server side of the api",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Businsoft Limited",
"license": "ISC",
"dependencies": {
"dropbox": "^5.2.1",
"express": "^4.17.1",
"isomorphic-fetch": "^2.2.1",
"nodemon": "^2.0.4"
}
}
I think this is the simpliest start with Elastic Beanstalk, but somehow it fails. Any idea to solve it?
Upvotes: 5
Views: 12291
Reputation: 2396
After debug for a while, I managed to figure out the issue.
In package.json
I need to remove this line:
"main": "app.js",
And the add the "start" in the "scripts" like this:
"scripts":
"start": "node app.js"
And then update the
app.listen(3000, () => {
console.log("Sever console log.")
});
to
const port = process.env.port || 3000;
app.listen(port, () => {
console.log("Sever console log.")
});
And then go to AWS Console > Elastic Beanstalk's environment > Configuration > Software Edit > add a properties at Environment properties
Name port
Value 8080
Finally reupload the source code, and it works.
Upvotes: 6