关于 Meteor.js
Meteor.js Meteor 是一个构建在 Node.js 之上的平台,用来开发实时网页程序。Meteor 位于程序数据库和用户界面之间,保持二者之间的数据同步更新。使用 Meteor,几小时之内就能开发出一个正常运行的实时网页程序。
编译部署 meteor 应用到服务器
将我们的应用编译到 build 中
1
2
|
cd myapp
meteor build --directory ../build
|
- 使用 rsync 同步到服务器上
bash
cd ../
rsync -avz build/bundle hostname:/home/myapp
安装 mongodb
1
|
sudo apt-get install mongodb-server
|
编写 upstart 脚本
1
|
sudo vi /etc/init/myapp.conf |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!upstart
description "Meteor Up - myapp"
author "Arunoda Susiripala, <arunoda.susiripala@gmail.com>"
start on runlevel [2345]
stop on runlevel [06]
respawn
limit nofile 65536 65536
script
# leave as 127.0.0.1 for security
export BIND_IP=127.0.0.1
# the port nginx is proxying requests to
export PORT=3000
# this allows Meteor to figure out correct IP address of visitors
export HTTP_FORWARDED_COUNT=1
# MongoDB connection string using myapp as database name
export MONGO_URL=mongodb://localhost:27017/myapp
# The domain name as configured previously as server_name in nginx
export ROOT_URL=https://myapp.wenzhixin.net.cn
exec node /home/myapp/bundle/main.js
end script
|
启动:
配置 nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
server {
listen 80;
server_name myapp.wenzhixin.net.cn;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:3000;
proxy_redirect off;
}
}
|
访问 myapp.wenzhixin.net.cn