gpt4 book ai didi

node.js - 如何安装部署在 AWS Elastic Beanstalk 上

转载 作者:太空宇宙 更新时间:2023-11-04 00:58:35 25 4
gpt4 key购买 nike

我正在尝试安装并部署在 AWS Elastic Beanstalk 上。我创建了一个node.js环境。

在本地,我做了:

npm install depoyd -g

我还创建了一个 .dpd 文件夹并执行了

dpd keygen

这是我的package.json 文件

{
"name": "my-api",
"version": "1.0.1",
"description": "My description",
"keywords": [],
"homepage": "http://www.example.com",
"author": "Me, Myslef and I",
"contributors": [],
"dependencies": {
"deployd": ">= 0"
},
"scripts": {
"start": "node server"
},
"engines": {
"node": "0.10.x",
"npm": "2.2.x"
}
}

这是我的server.js 文件

// requires
var deployd = require('deployd'); //API

// configure database etc.
var server = deployd({
port: process.env.PORT || 5000,
env: 'production',
db: {
host: 'ds12345.mongolab.com',
port: 12345,
name: 'my-api',
credentials: {
username: admin,
password: mypassword
}
}
});

// heroku requires these settings for sockets to work
server.sockets.manager.settings.transports = ["xhr-polling"];

// start the server
server.listen();

// debug
server.on('listening', function() {
console.log("Server is listening on port: " + process.env.PORT);
});

// Deployd requires this
server.on('error', function(err) {
console.error(err);
process.nextTick(function() { // Give the server a chance to return an error
process.exit();
});
});

这是我的 ProcFile:

web: node server

当我使用文件创建 zip 文件并将其“上传并部署”到仪表板时,“运行状况”状态为绿色,但应用程序 URL 显示

502 Bad Gateway

nginx/1.6.2

感谢您的帮助

最佳答案

我只是忘记了凭据中的引号。

// configure database etc. 

var server = deployd({
port: process.env.PORT || 5000,
env: 'production',
db: {
host: 'ds12345.mongolab.com',
port: 12345,
name: 'my-api',
credentials: {
username: 'admin',
password: 'mypassword'
}
}
});

关于node.js - 如何安装部署在 AWS Elastic Beanstalk 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28319597/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com