Meteor Up - Meteor deployment tool
미티어를 사용하면서 가장 불편했던 것이 서버에 디플로이 하는것이 힘들다는 것이었다. 방법들은 여러가지가 있지만(물론 내 블로그에도 있다) 그중에 하나는 물론 하나의 툴을 사용하는 것이었다.
이 글에서는 Meteor up 에 대해서 설명한다.
Meteor up의 특징은 설정 파일 하나만 만들어도 nodejs, mongoDB, PhantomJS 등의 dependency들을 설치해줄뿐만 아니라 mup deploy라는 강력한 명령어 하나로 서버에 디플로이할 수 있다 또한 mup start, stop, restart 명령어를 통해 손쉽게 앱을 켜고 끌수 있다
현재 진행하는 서버는 https://www.digitalocean.com에서 서비스되는 Ubuntu 14.04이고 nodejs v0.12.0, npm 이 설치되어 있다.
Meteor 설치
curl https://install.meteor.com/ | sh
미티어의 좋은점 중에 하나는 이 간단한 설치 코드라고 생각한다 :)
nginx 설치
sudo apt-get install nginx
- ngnix 설정
cd /etc/nginx/sites-available/ sudo vi custom
- /etc/nginx/sites-available/custom
server { listen *:80; server_name mycustomappname.com; access_log /var/log/nginx/app.dev.access.log; error_log /var/log/nginx/app.dev.error.log; location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header X-Forwarded-For $remote_addr; } }
- Create a Symbolic Link for custom
ln -s /etc/nginx/sites-available/custom /etc/nginx/sites-enabled/custom
- default 삭제
rm /etc/nginx/sites-enabled/default
-- 만약을 위해 테스트!
nginx -t
- Restart nginx
sudo service nginx restart
ip로 접속했을때 이와 같이 뜬다면 성공!
Meteor up 설치
sudo npm install -g mup
Create a New Meteor Project
meteor create myApp cd myApp
Setup Meteor up
- Initialize mup
mup init vi mup.json
자신의 입맛에 맞게 설정을 바꿔준다
{ // Server authentication info "servers": [ { "host": "my-ip-address", "username": "root", "password": "password" // or pem file (ssh based authentication) //"pem": "~/.ssh/id_rsa" } ], // Install MongoDB in the server, does not destroy local MongoDB on future setup "setupMongo": true, // WARNING: Node.js is required! Only skip if you already have Node.js installed on server. "setupNode": false, // WARNING: If nodeVersion omitted will setup 0.10.36 by default. Do not use v, only version number. "nodeVersion": "0.12.0", // Install PhantomJS in the server "setupPhantom": true, // Application name (No spaces) "appName": "myApp", // Location of app (local directory) "app": ".", // Configure environment "env": { "PORT": "3000", // The port you want to bind to on your server. "UPSTART_UID": "meteoruser", // The user you want to run meteor as. "ROOT_URL": "http://mycustomappname.com" }, // Meteor Up checks if the app comes online just after the deployment // before mup checks that, it will wait for no. of seconds configured below "deployCheckWaitTime": 15 }
- Setup mup
sudo visudo
아래의 줄을 %sudo ALL=(ALL) ALL 이렇게 수정한다 %sudo ALL=(ALL) NOPASSWD:ALL
sshpass 설치
sudo apt-get install sshpass sudo apt-get update
mup setup
mup setup
여기서부턴 시간이 오래걸리므로 딴짓을 하도록 하자 :)
위와 같이 나왔다면 아주 성공! 아니라면 처음부터 다시...
Deploy!!!
mup deploy
자신의 url로 접속해보면...
자신의 서버를 갖는다는건 정말 힘든일이다. 처음 설정을 snapshot을 찍어두고(snapshot이란 쉽게 말하면 서버 백업이라고 생각하면 된다.) 실패하면 다시 그 snapshot을 restore해서 다시 세팅해보고 하는 작업을 반복하다보면 어느새 다른 블로그에서 따라하던 코드들을 이해하게 된다.
내가 사용하는 서버는 Digitalocean에서 제공하는 서버인데 싱가폴로 위치를 설정하면 그렇게 느리지도 않고 속도도 빨라 쓸만하다.
아래 경로로 들어가면 digitalocean 10달러 쿠폰을 얻을 수 있으므로 무료로 사용해보도록 하자
https://www.digitalocean.com














