保持流星在亚马逊 EC2 上运行 [英] Keep meteor running on amazon EC2

查看:31
本文介绍了保持流星在亚马逊 EC2 上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 Amazon EC2 服务器上运行的简单流星应用程序.一切都很好.我通过项目目录中的 meteor 与我的用户手动启动它.

但是,我希望这个应用程序能够

  1. 开机运行
  2. 免于挂断

我尝试通过 nohupmeteor & 运行它,但是当我尝试注销 EC2 实例时,我收到您有正在运行的作业"消息.继续注销会停止应用.

如何让应用在启动时启动并保持运行(除非它因某种原因崩溃)?

解决方案

安装 forever 并使用启动脚本.

$ npm install -g 永远

我有几个用于管理生产环境的脚本 - 启动脚本如下所示:

#!/bin/bash永远停止导出 MAIL_URL=...导出 MONGO_URL=...导出 MONGO_OPLOG_URL=...出口端口=3000导出 ROOT_URL=...永远开始/home/ubuntu/apps/myapp/bundle/main.js退出 0

方便的是,它还将附加到 ~/.forever 中的日志文件,该文件将显示运行应用程序时遇到的任何错误.您可以通过以下方式获取日志文件的位置以及有关您的应用的其他统计信息:

$ 永久列表

要让您的应用在启动时启动,您需要做一些适合您的 linux 风格的事情.您也许可以将启动脚本放在 /etc/rc.local 中.对于 ubuntu,请参阅这个问题.>

另请注意,如果在生产中使用它,您真的应该捆绑您的应用.有关差异的更多详细信息,请参阅此比较.

I have a simple meteor app that I'm running on an Amazon EC2 server. Everything is working great. I start it manually with my user via meteor in the project directory.

However, what I would like is for this app to

  1. Run on boot
  2. Be immune to hangups

I try running it via nohup meteor &, but when I try to log out of the EC2 instance, I get the "You have running jobs" message. Continuing to log out stops the app.

How can I get the app to start on startup and stay up (unless it crashes for some reason)?

解决方案

Install forever and use a start script.

$ npm install -g forever

I have several scripts for managing my production environment - the start script looks something like:

#!/bin/bash

forever stopall

export MAIL_URL=...
export MONGO_URL=...
export MONGO_OPLOG_URL=...
export PORT=3000
export ROOT_URL=...
forever start /home/ubuntu/apps/myapp/bundle/main.js

exit 0

Conveniently, it will also append to a log file in ~/.forever which will show any errors encountered while running your app. You can get the location of the log file and other stats about your app with:

$ forever list

To get your app to start on startup, you'd need to do something appropriate for your flavor of linux. You can maybe just put the start script in /etc/rc.local. For ubuntu see this question.

Also note you really should be bundling your app if using it in production. See this comparison for more details on the differences.

这篇关于保持流星在亚马逊 EC2 上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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