为什么我们需要部署一个流星应用程序而不是仅仅启动它? [英] Why do we need to deploy a meteor app instead of just starting it?

查看:54
本文介绍了为什么我们需要部署一个流星应用程序而不是仅仅启动它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

众所周知,我们只需在终端中输入 meteor 即可运行 Meteor 应用程序.默认情况下,它将启动服务器并使用端口 3000.

As we all know, we can run a meteor app by just typing meteor in a terminal. By default it will start a server and use port 3000.

那为什么我需要使用 MUP 等来部署它.

So why do I need to deploy it using MUP etc.

我可以将其配置为使用端口 80 或使用 nginx 为应用程序路由到端口 80.所以端口不是重点.

I can configure it to use port 80 or use nginx to route to port 80 for the app. So the port is not the point.

假设meteor 运行在具有公共IP 地址的VPS 或云服务器上,而不是个人计算机上.

Assume meteor is running on a VPS or cloud server with public IP address, not a personal computer.

推荐答案

MUP 做了一些你可以自己做的额外事情:

MUP does a few extra things you can do yourself:

它使用 meteor build bundle 将代码捆绑"到一个文件中javascript 是一个文件,css 是另一个;它经过缩小和模糊处理,因此加载更小、速度更快,并且在客户端上更不容易破译.

it 'bundles' the code into a single file, using meteor build bundle the javascript is one file, and css another; it's minified, and obfuscated so it's smaller and faster to load, and less easy to decipher on the client.

在生产环境中运行时,某些软件包也将被删除.例如,用于查找集合等的实用工具集meteorToys 并未按照其包中的说明捆绑到生产包中.这确保您不会部署具有安全漏洞的代码(流星玩具基本上会打开客户端删除/更新等...如果您不小心)

some packages are also meant to be removed when running in production. For example meteorToys, the utility toolset to look up collections and much more, is not bundled into the production bundle, as per the instructions in its package. This insures you don't deploy code with security vulnerabilities (Meteor toys basically opens up client side delete / updates etc... if you're not careful)

因此,简而言之,它会安装您网站的最小版本,确保仅用于开发的内容不会推送到生产环境.

So, in short, it installs a minimal version of your site, making sure that what's meant for development only doesn't get push to a production environment.

这样做的另一个原因是您不需要生产服务器上的所有 Meteor 构建工具;这可以加起来很多东西,特别是如果你让缓存持续一段时间......

On other reason to do this, is that you don't need all the Meteor build tools on your production server; that can add up to a lot of stuff, especially if you keep caches going for a while...

我相信它还负责连接到远程 MongoDB 实例(至少在免费流星站点上曾经是这种情况),它比在与 Web 服务器相同的实例上运行更具可扩展性和容错性,以及配置存储等...如果需要.

I believe it also takes care of hooking up to a remote MongoDB Instance (at least it used to be the case on the free meteor site) which is more scalable and fault tolerant than running on the same instance as the web server, as well as provision storage etc... if needed.

基本上,要自己手动部署 Meteor 应用程序,您需要:

basically, to deploy a Meteor app yourself manually, you need to:

在您的开发箱上:

  • meteor build bundle 将您的应用程序转换为 tar 文件(使用与您将使用的操作系统对应的架构标志)
  • meteor build bundle your app to a tar file (using the architecture flag corresponding to the OS you will use)

在服务器上:

  • 安装 node v0.10(或 Meteor 所需的当前 node 版本)

  • install node v0.10 (or whatever is the current version of node required by Meteor)

您可能需要安装 Fiber@1.0.5(但我相信这现在已经是meteor install 的一部分)

you might have to install Fiber@1.0.5 (but I believe this is now part of meteor install already)

解压包,进入bundle/programs/server/并运行npm install

使用 bundle 文件夹中的 node main.js 运行服务器.

run the server with node main.js in the bundle folder.

这篇关于为什么我们需要部署一个流星应用程序而不是仅仅启动它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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