简体   繁体   English

亚马逊AWS Node.js WebSocket

[英]Amazon AWS Node.js WebSocket

With the Amazon AWS Free Usage Tier, how should I deploy a simple Node.js WebSocket chat server that uses the ws & pg modules? 使用Amazon AWS Free Usage Tier,我应该如何部署使用wspg模块的简单Node.js WebSocket聊天服务器

  1. If you can: How to deploy a Node.js WebSocket server to Amazon Elastic Beanstalk? 如果可以: 如何将Node.js WebSocket服务器部署到Amazon Elastic Beanstalk?

  2. Otherwise, what are all the steps I should take to set it up using EC2 directly? 否则,我应该采取什么步骤来直接使用EC2进行设置?

  3. Or, should I do it with OpsCloud? 或者,我应该使用OpsCloud吗?

You CAN use Elastic Beanstalk with the free usage tier. 您可以将Elastic Beanstalk与免费使用层一起使用。 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/ 但是,如果您想同时运行Postgres和Node.js,您可能会发现需要滚动自己的EC2实例以保持免费使用限制 - 请在此处查看: 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. EB确实使部署相对简单,如果您正确地进行开发设置,EB将安装您需要的额外节点模块。

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. 无论如何,在开发时你会发现你需要安装新模块 - 我相信你已经熟悉了npm install机制。 What you need to add to that is the --save option, so 您需要添加的是--save选项,所以

npm install pg

becomes

npm install --save pg

This then adds that package to the dependencies section of the package.json file. 然后,将该包添加到package.json文件的dependencies部分。 When you deploy to EB or any other dev ops system, these dependencies are automatically installed (the system runs npm install ). 部署到EB或任何其他开发系统时,会自动安装这些依赖项(系统运行npm install )。 If you are cloning from a repository onto your server, then running npm install yourself will install those modules. 如果要从存储npm install到服务器上,那么自己运行npm install将安装这些模块。

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. 值得注意的是,您的node_modules目录不应与您的代码一起提供 - 让系统在部署时构建它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM