0

I am specifically talking about an app bundle running on my own server.

I have a Meteor app running using forever in ~/bundle and my git repo is at ~/project. I keep different release bundle tarballs in ~/release.

~/release
  |-0.1.0.tar.gz
  |-0.1.1.tar.gz
  |-0.2.0.tar.gz

After pulling in changes from git and switching to the latest release, I want to bundle my new version and take advantage of hot-code reloading and (hopefully?) keeping client connections alive. What is the best way to do this?

Note: I am also using nginx; so will this affect the process in any way? i.e. will it kill open client connections? do I have to reload nginx after updating to newer app version?

Thanks.

alnafie
  • 10,558
  • 7
  • 28
  • 45
  • possible duplicate of [Update deployed meteor app while running with minimum downtime - best practice](http://stackoverflow.com/questions/22065873/update-deployed-meteor-app-while-running-with-minimum-downtime-best-practice) – David Weldon Jun 30 '14 at 23:24
  • Instead of rolling your own solution, use https://github.com/arunoda/meteor-up. – Andrew Mao Jul 01 '14 at 15:21

1 Answers1

0

You could use a script like this.

Make sure define your server in your ssh config file, e.g

Host yourserver
User youruser
Port 22
Hostname yourapp.com
IdentityFile ~/.ssh/yourkeyfile.pem
TCPKeepAlive yes
IdentitiesOnly yes

Then you could have a bash script like this:

#!/bin/bash
cd ~/Desktop/yourappdirectory
rm -f ~/Desktop/yourapp.tar.gz
meteor bundle ~/Desktop/yourapp.tar.gz
scp ~/Desktop/yourapp.tar.gz yourserver:~/yourapp.tar.gz
ssh yourserver  <<'ENDSSH'
cd ~/
tar -xzf yourapp.tar.gz
sudo rm -rf yourapp
mv bundle yourapp
cd yourapp/programs/server/node_modules
rm -rf fibers
rm -rf bcrypt
sudo npm install fibers@1.0.1
sudo npm install bcrypt
cd ~/yourapp/programs/server/npm/mongo-livedata/main
rm -r mongodb
sudo npm install mongodb@1.4.1
cd ~/
sudo forever stop ~/yourapp/main.js
sudo MONGO_URL=mongodb://user:pass@ip:27017/meteor PORT=3000 ROOT_URL=https://yoursite.com forever start ~/yourapp/main.js
ENDSSH

Then just run the bash and it would upload and deploy your app for you. Just a note I couldn't put a release version in so stuff just uploads to ~/yourapp.tar.gz then unbundles into ~/yourapp

The meteor app would then be hot code reloaded on any clients if they're on the site.

Tarang
  • 75,157
  • 39
  • 215
  • 276