asp*_*pin 7 meteor meteor-up modulus.io
我有点好奇,如果Meteor Up(或其他Meteor应用程序部署像Modulus这样的过程)做的事情与复制Meteor应用程序,启动tmux会话以及只是运行meteor以在服务器上启动应用程序相比有任何意义.谢谢提前!
pho*_*cks 12
Meteor Up和Modulus似乎只运行node.js和Mongodb.它们在打包生产后运行您的应用程序meteor build.这可能会让您的应用程序在性能方面具有优势.
可以在tmux或屏幕会话中运行meteor .我meteor run --settings settings.json --production用来传递设置并使用缩小代码等的生产模式.您还可以使用像Nginx这样的代理转发器将请求转发到端口80(http)和443(https).
这里参考我的Nginx配置:
server {
listen 80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate /etc/ssl/private/example.com.unified.crt;
ssl_certificate_key /etc/ssl/private/example.com.ssl.key;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/ssl/private/example.com.unified.crt;
ssl_certificate_key /etc/ssl/private/example.com.ssl.key;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Run Code Online (Sandbox Code Playgroud)
通过使用此方法,所有内容都包含在流星容器中,您可以通过流星观察更改等.但是,您的服务器上可能会有一些额外的开销.我不确定多少,因为我没有测试两种方式.
我通过使用这种方法找到的唯一问题是在重启时自动运行所有内容并不容易,比如自动运行tmux然后启动meteor,而不是使用特殊设计的工具,如Node.js Forever或PM2,它们在服务器时自动启动重启.因此,您必须手动登录服务器并运行meteor.如果您使用tmux或屏幕轻松完成此操作,请告诉我.
编辑:
我已经设法让Meteor在系统启动时启动,/etc/rc.local文件中包含以下行:
sudo -H -u ubuntu -i /usr/bin/tmux new-session -d '/home/ubuntu/Sites/meteorapp/run_meteorapp.sh'
Run Code Online (Sandbox Code Playgroud)
run_meteorapp.sh一旦系统启动,此命令将在tmux会话中运行shell脚本.在run_meteorapp.sh我有:
#!/usr/bin/env bash
(cd /home/ubuntu/Sites/meteorapp && exec meteor run --settings settings.json --production)
Run Code Online (Sandbox Code Playgroud)
如果您查看Meteor Up Github页面:https://github.com/arunoda/meteor-up,您可以看到它的作用.
如:
特征
单一命令服务器设置单一命令部署多服务器部署环境变量管理支持settings.json基于密码或私钥(pem)的服务器身份验证访问,来自终端的日志(支持日志拖尾)支持多个流星部署(实验)
服务器配置
如果应用程序崩溃(永久使用),则自动重新启动服务器重新启动后自动启动(使用upstart)Stepdown User Privileges如果部署失败,则恢复到以前的版本安全的MongoDB安装(可选)预安装的PhantomJS(可选)
所以是的......它确实做得更多......
| 归档时间: |
|
| 查看次数: |
679 次 |
| 最近记录: |