如何在AWS Elastic Beanstalk上安装Deployd

时间:2015-02-04 10:56:54

标签: node.js amazon-web-services npm elastic-beanstalk deployd

我正在尝试在AWS Elastic Beanstalk上安装deployd。 我创建了一个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文件时,"上传和部署"它进入仪表板,"健康"状态为绿色,但应用程序网址显示

  

502 Bad Gateway

     

的nginx / 1.6.2

感谢您的帮助

1 个答案:

答案 0 :(得分:1)

我忘了凭据中的引号。

// 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'
    }
  }
});