亚马逊AWS的Node.js的WebSocket [英] Amazon AWS Node.js WebSocket

查看:376
本文介绍了亚马逊AWS的Node.js的WebSocket的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着亚马逊AWS免费使用层,应该怎么部署简单的Node.js的WebSocket的聊天服务器使用该 WS 和放大器; 皮克模块?

  1. 如果您可以:?如何使Node.js的WebSocket服务器部署到亚马逊弹性魔豆

  2. 否则,什么都是我应该采取直接使用EC2来进行设置的步骤是什么?

  3. 或者,我应该做它OpsCloud?

解决方案

您可以使用弹性魔豆的免费使用层。但是,如果你想同时运行的Postgres和Node.js的,你可能会发现你需要推出自己的EC2实例,以保持自由使用限制范围内 - 点击这里:的 http://aws.amazon.com/free/

EB并使其相对易于部署,而且如果你正确地做你的开发设置,EB将安装你需要额外的节点模块。

在任何情况下,开发时,你会发现你需要安装新的模块 - 我敢肯定,你已经熟悉了 NPM安装机制。您需要添加到什么是 - 保存选项,这样

  NPM安装PG
 

变为

  NPM安装--save皮克
 

这则补充说,包到的package.json 文件的相关部分。当你部署到EB或任何其他开发OPS系统,这些依赖关系被自动安装(系统运行 NPM安装)。如果您是从一个仓库克隆到你的服务器,然后在运行 NPM安装自己将安装这些模块。

希望这可以帮助你得到你需要在服务器上安装的模块。值得一提的是,你的 node_modules 目录不应该附带code - 让部署在系统建立它

With the Amazon AWS Free Usage Tier, how should I deploy a simple Node.js WebSocket chat server that uses the ws & pg modules?

  1. If you can: How to deploy a Node.js WebSocket server to Amazon Elastic Beanstalk?

  2. Otherwise, what are all the steps I should take to set it up using EC2 directly?

  3. Or, should I do it with OpsCloud?

解决方案

You CAN use Elastic Beanstalk with the free usage tier. However if you want to run both Postgres and Node.js, you might find you need to roll your own EC2 instance to remain within the free usage constraints - check here: http://aws.amazon.com/free/

EB does make it relatively simple to deploy, and if you do your development setup correctly, EB will install the extra node modules you need.

In any case, when developing you will find you need to install new modules - I'm sure you're familiar with the npm install mechanism. What you need to add to that is the --save option, so

npm install pg

becomes

npm install --save pg

This then adds that package to the dependencies section of the package.json file. When you deploy to EB or any other dev ops system, these dependencies are automatically installed (the system runs npm install). If you are cloning from a repository onto your server, then running npm install yourself will install those modules.

Hopefully this helps you get the modules you need installed on the server. It's worth noting that your node_modules directory should not be shipped with your code - let the system build it when deploying.

这篇关于亚马逊AWS的Node.js的WebSocket的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆