创建在单个服务器上运行的meteor.js 应用程序的多个实例所需的主要步骤是什么? [英] what are the major steps required to create multiple instances of a meteor.js application running on a single server?

查看:23
本文介绍了创建在单个服务器上运行的meteor.js 应用程序的多个实例所需的主要步骤是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计了一个meteor.js 应用程序,它在本地主机上运行良好,甚至在部署到互联网时也是如此.现在我想创建一个注册站点,该站点将为在后端注册的每个客户端启动应用程序的新实例.假设注册站点有一个meteor.js 应用程序和python 或javascript,需要采取哪些高级步骤来实现这一点?

I have designed a meteor.js application and it works great on localhost and even when deployed to the internet. Now I want create a sign-up site that will spin up new instances of the application for each client who signs up on the back-end. Assuming a meteor.js application and python or javascript for the sign-up site, what high level steps need to be taken to implement this?

我正在寻找一个更正确和完整的答案,采用我想象中的糟糕版本的形式:

I am looking for a more correct and complete answer that takes the form of my poorly imagined version of this:

  1. 使用 node 或 python 之类的东西来调用一个 shell 脚本,该脚本可能会或可能不会作为 sudo 运行
  2. 该脚本可能会创建一个新文件夹来保存实例特定的内容(如客户端文件、配置和/或该实例数据库).
  3. 脚本或 Python 代码会将应用程序实例部署到该文件夹​​和特定端口
  4. Python 可能会向诸如 Pound 之类的工具添加配置信息以将子域转发到端口莉>
  5. 其他事情......!?
  1. Use something like node or python to call a shell script that may or may not run as sudo
  2. That script might create a new folder to hold instance specific stuff (like client files, config, and or that instances database).
  3. The script or python code would deploy an instance of the application to that folder and on a specific port
  4. Python might add configuration information to a tool like Pound to forward a subdomain to a port
  5. Other things....!?

我不太了解这里需要采取的高级步骤,所以如果有人能提供这些步骤,甚至是一些有用的工具或教程,我将不胜感激.

I don't really understand the high level steps that need to be taken here so if someone could provide those steps and maybe even some useful tools or tutorials for doing so I'd be extremely grateful.

推荐答案

首先让我说一下,我认为启动同一个应用程序的多个实例是一个糟糕的设计选择.如果这是一个止损措施,这是我的建议:

  1. 创建一个易于部署的档案.(捆绑应用程序,必要时重新安装光纤,重新压缩).使用脚本创建新实例时,将存档部署(解压缩)到新文件夹.

  1. Create an archive that can be readily deployed. (Bundle the app, reinstall fibers if necessary, rezip). Deploy (unzip) the archive to a new folder when a new instance is created using a script.

创建一个初始化脚本的模板,并使用永远或守护进程或耶稣等在重启时启动站点并在正常运行期间保持站点运行.请参阅通过安装meteor 将Meteor 部署到VM如何启动 node.js 服务器作为一个守护进程? 例如.部署新实例时,使用新值(即端口号、数据库名称、文件夹)填充模板.将填写好的模板复制到 init.d 并链接到运行级别.或者,在 init.d 中创建一个脚本来执行其他脚本以启动站点.

Create a template of an init script and use forever or daemonize or jesus etc to start the site on reboot and keep the sites up during normal operation. See Meteor deploying to a VM by installing meteor or How does one start a node.js server as a daemon process? for examples. when a new instance is deployed populate the template with new values (i.e. port number, database name, folder). Copy the filled out template to init.d and link to the runlevel. Alternatively, create one script in init.d that executes other scripts to bring up the site.

每个实例都应该监听自己的端口,所以你需要一个反向代理.当您更改配置时,AFAIK、Apache 和 Nginx 需要重新启动,因此您可能需要查看 Hipache https://github.com/dotcloud/hipache.Hipache 使用 redis 来存储配置信息.添加新实例需要给redis添加一个key.有一个 Hipache 的实验性端口,将功能引入 Nginx https://github.com/samalba/hipache-nginx

Each instance should be listening to its own port, so you'll need a reverse proxy. AFAIK, Apache and Nginx require restarts when you change the configuration, so you'll probably want to look at Hipache https://github.com/dotcloud/hipache. Hipache uses redis to store the configuration information. Adding the new instance requires to add a key to redis. There is an experimental port of Hipache that brings the functionality to Nginx https://github.com/samalba/hipache-nginx

DNS 更新怎么样?创建新实例后,是否需要在 DNS 配置中添加新记录?

What about DNS updates? Once you create a new instance, do you need to add a new record to your DNS configuration?

这篇关于创建在单个服务器上运行的meteor.js 应用程序的多个实例所需的主要步骤是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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