简体   繁体   English

在EC2 AWS服务器上部署流星应用程序

[英]deploying meteor app on a EC2 AWS server

i'm currently working on a school project : 我目前正在从事一个学校项目:

I have to use PeerJS, Meteor and WebRTC to make a video chat app. 我必须使用PeerJS,Meteor和WebRTC来制作视频聊天应用程序。

Mine is based on this tutorial , only with added CSS. 我的基于本教程 ,仅添加了CSS。

I successfully managed to create one that works locally (everything works fine on localhost:3000 once the 我成功地创建了一个可以在本地工作的计算机(在localhost:3000上,一切正常

meteor 流星

command is run in the project folder. 命令在项目文件夹中运行。

I'm working on windows 10, and I used mupx to deploy the app on my EC2 server. 我正在Windows 10上工作,我使用mupx将应用程序部署在EC2服务器上。

i followed this tutorial and everything worked fine, i can access my app, login and see my webcam feed. 我遵循了本教程 ,一切正常,我可以访问我的应用程序,登录并查看我的网络摄像头。 but once i try to call another user, the link isn't made. 但是一旦我尝试呼叫其他用户,就不会建立链接。 i think it's because the mongoDB or meteor service lacks something but i can't figure out what. 我认为这是因为mongoDB或流星服务缺少某些内容,但我不知道是什么。

My mup.json looks like this : 我的mup.json看起来像这样:

{
  "servers": [
    {
      "host": "IP.OF.METEOR.APP.EC2",
      "username": "ubuntu",
      "pem": "C:/Path/to/file.pem"
    }
  ],
  "setupMongo": true,
  "enableUploadProgressBar": true,
  "appName": "PeerChat",


  "app": "C:/pth/to/PeerChat",
    "buildOptions": {
     "debug": true,
     "executable": "meteor"
  },
  "env": {
      "PORT" : 80,
      "ROOT_URL" : "http://ec2-ip-to-meteor-app.us-west-2.compute.amazonaws.com",
      "MONGO_URL" : "http://IP.TO.MONGO.EC2:27017"
  },
  "deployCheckWaitTime": 300
}

Could someone give me advice on how to successfully deploy my app ? 有人可以给我一些有关如何成功部署我的应用程序的建议吗? I've been trying lots and lots of things but none worked so far. 我一直在尝试很多事情,但到目前为止没有任何工作。

Thanks for your help ! 谢谢你的帮助 !

Recently browsers changed to prevent webrtc over http. 最近,浏览器进行了更改,以防止通过HTTP的webrtc。 If you try to run it you'll get some kind of access denied error in your console log. 如果尝试运行它,则会在控制台日志中收到某种拒绝访问的错误。

It means that everything needs to be run using https. 这意味着所有内容都需要使用https运行。 In your case this means Meteor and the peerjs-server. 在您的情况下,这意味着Meteor和peerjs服务器。

Looking at the mupx documentation, I'm going to assume that's working ok for you, it uses nginx itself, so it should be ok. 看一下mupx文档,我将假定对您来说一切正常,它使用了nginx本身,因此应该没问题。 Doing it yourself is quite possible, but some sysadmin capability is required. 您自己可以这样做,但是需要某些sysadmin功能。 That is also true (to a lesser extent with peerjs-server) 这也是正确的(在较小程度上与peerjs-server一起)

Peerjs server Peerjs服务器

The peerjs-server is available at https://github.com/peers/peerjs-server As it stands it can be run from the command line, but the problem is that tools like nginx/Passenger don't do command line options, so I made a fork that accepts environment variables. 可以在https://github.com/peers/peerjs-server上找到peerjs服务器。按其现状,它可以从命令行运行,但是问题是像nginx / Passenger这样的工具不能执行命令行选项,所以我做了一个接受环境变量的fork。 My fork is at https://github.com/mikkelking/peerjs-server 我的叉子在https://github.com/mikkelking/peerjs-server

This is the startup file for peerjs-server which uses a thing called forever. 这是peerjs-server的启动文件,它使用一个称为ever的东西。 https://github.com/foreverjs/forever https://github.com/foreverjs/forever

A simple CLI tool for ensuring that a given script runs continuously (ie forever). 一个简单的CLI工具,用于确保给定脚本连续运行(即永远运行)。

Pre-requisites: 先决条件:

  • Nodejs Nodejs的
  • A User called peerjs 一个名为peerjs的用户
  • My port of peerjs-server unpacked to /var/www/peerjs 我的peerjs-server端口解压到/ var / www / peerjs
  • An understanding of how to install and run forever 了解如何永久安装和运行

Script to run peerjs-server: 运行peerjs-server的脚本:

#!/bin/bash
export PEERJS_PORT=9000;
export PEERJS_KEY=some-unique-string;
export PEERJS_SSLKEY=/etc/nginx/ssl/myserver.key;
export PEERJS_SSLCERT=/etc/nginx/ssl/myserver.pem;
export PEERJS_DEBUG=1;
cd /var/www/peerjs

forever start -l forever.log --append -o out.log -e err.log ./bin/peerjs --debug 2&>1 >./peerjs.log

This script will ensure that peerjs will run even after crashing, and will survive a reboot of the server. 该脚本将确保peerjs即使在崩溃后也将运行,并且在重新启动服务器后仍可幸免。

You might also need this file: 您可能还需要以下文件:

~peerjs/.forever/config.json 〜peerjs / .forever / config.json

{
  "root": "/home/peerjs/.forever",
  "pidPath": "/home/peerjs/.forever/pids",
  "sockPath": "/home/peerjs/.forever/sock",
  "loglength": 100,
  "logstream": false,
  "columns": [
    "uid",
    "command",
    "script",
    "forever",
    "pid",
    "id",
    "logfile",
    "uptime"
  ]
}

I hope this helps. 我希望这有帮助。

If this is just a demo, you don't need to go and set up a whole web site. 如果这只是一个演示,则无需建立整个网站。 You can do it with a port forward to allow a second machine to participate. 您可以使用端口转发来允许第二台计算机参与。

Let's say you are running meteor on port 3000 on your local machine. 假设您在本地计算机的端口3000上运行流星。 Work out what your local network ip address is, something like 192.168.1.101 计算出您的本地IP地址是什么,例如192.168.1.101

On the second machine do a port forward with a command like this: 在第二台计算机上,使用以下命令执行端口转发:

ssh -L 3000:192.168.1.101:3000 localhost

It will ask you to provide the password of the local user. 它将要求您提供本地用户的密码。

Now that user can go to localhost:3000 and access your meteor app. 现在,该用户可以转到localhost:3000并访问您的流星应用程序。 Video calling will be allowed, because the browser thinks you are on the local machine 允许进行视频通话,因为浏览器认为您在本地计算机上

The other option is to use an anonymous window on the same machine and log in as a different user. 另一种选择是在同一台计算机上使用匿名窗口,然后以其他用户身份登录。 Not as good as doing it on 2 computers though. 虽然不如在2台计算机上执行。

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

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