【问题标题】:How to install Deployd on AWS Elastic Beanstalk如何在 AWS Elastic Beanstalk 上安装 Deployd
【发布时间】:2015-04-03 20:52:33
【问题描述】:

我正在尝试安装部署在 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 网关错误

nginx/1.6.2

感谢您的帮助

【问题讨论】:

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


    【解决方案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'
        }
      }
    });
    

    【讨论】:

    • 我还发现全局安装部署不行。您必须在已部署的应用程序文件夹上安装 deployd: cd my-app-folder 然后 npm install deployd
    • 您不应发布更多信息作为答案。编辑您的原始问题。如果人们看到已经有 1 个答案,他们就不太可能帮助您。
    猜你喜欢
    • 2021-01-07
    • 2017-03-26
    • 2013-07-08
    • 2015-09-26
    • 2018-07-01
    • 2018-05-25
    • 2020-10-13
    • 2014-10-15
    • 2021-02-01
    相关资源
    最近更新 更多