Short of posting a few long gists that configure your servers, I can steer you in the right direction:
1 & 2 & 3. The pattern is to set up a post-receive
hook on each machine.
The hook should:
- clone the repo to a tmp directory
- call
meteor bundle
(produces a.tar.gz
file) - stop your running meteor application
- Extract bundle to a known application directory
- start your meteor application
You can set up a script in init.d
which uses forever
to operate meteor, eg. /etc/init.d/meteor start|stop
You can also add your required configuration variables - eg MONGO_URL
example of starting meteor:
echo "$(date +'%Y-%m-%d %T,000') INFO $SERVICE_NAME started" >> $LOG_DIR/forever.log
export MONGO_URL=''
export PORT=3000
export ROOT_URL=myserver.myapp.com
export METEOR_SETTINGS="\`cat /path/to/production/settings.json\`"
export MAIL_URL=mail.myapp.com
sudo -u meteor -H -E forever -l $LOG_DIR/forever.log -o $LOG_DIR/out.log -e $LOG_DIR/err.log --minUptime 30000 --spinSleepTime 5000 -a -s start $WWW_APP_DIR/main.js
;;
4 . unless you run meteor as root, no luck with port 80 - you're better off having nginx sit infront of Meteor and serve up static resources anyway - so get an nginx config, eg.
server {
listen 3000;
server_name localhost;
# this should include any files / directories that belong to /public
location ~ "^/(resources/|robots.txt|humans.txt|favicon.ico)" {
root /path/to/bundle/programs/client/app/;
access_log off;
expires max;
}
# this is any assets that belong in packages
location ~ "^/packages" {
root /path/to/bundle/programs/client/;
access_log off;
expires max;
}
# this is for the main css & js
location ~* "^/[a-z0-9]{40}\.(css|js)$" {
root /path/to/bundle/programs/client;
access_log off;
expires max;
}
# this is for any sockets
location /sockjs/ {
proxy_pass http://meteor;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
location / {
proxy_pass http://meteor;
# dont know if this is missing some stuff
}
}