Update deployed meteor app while running with minimum downtime - best practice
meteor
Solution
You can't do this without killing the node process, but I haven't found that really matters. What's actually more annoying is the browser refresh on the client, but there isn't much you can do about that.
First, let's assume the application is already running. We start our app via forever with a script like the one in my answer here. I'd show you my whole upgrade script but it contains all kinds of Edthena-specific stuff, so I'll outline the steps we take below:
Build a new bundle. We do this on the server itself, which avoids any missing fibers issues. The bundle file is written to `/home/ubuntu/apps/edthena/edthena.tar.gz`.
We `cd` into the `/home/ubuntu/apps/edthena` directory and `rm -rf bundle`. That will blow away the files used by the current running process. Because the server is still running in memory it will keep executing. However, this step is problematic if your app regularly does uncached disk operatons like reading from the `private` directory after startup. We don't, and all of the static assets are served by nginx, so I feel safe in doing this. Alternatively, you can move the old `bundle` directory to something like `bundle.old` and it should work.
`tar xzf edthena.tar.gz`
`cd bundle/programs/server && npm install`
`forever restart /home/ubuntu/apps/edthena/bundle/main.js`
There really isn't any downtime with this approach - it just restarts the app in the same way it would if the server threw an exception. Forever also keeps the environment from your original script, so you don't need to specify your environment variables again.
Finally, you can have a look at the log files in your `~/.forever` directory. The exact path can be found via `forever list`.
Problem
I run my meteor app on EC2 like this: `node main.js` (in tmux session) Here are the steps I use to update my meteor app: 1) meteor bundle app.tgz 2) scp app.tgz EC2-server:/path 3) ssh EC2-server and attach to tmux 4) kill the current meteor-node process by C-c 5) extract app.tgz 6) run "node main.js" of the extracted app.tgz Is this the standard practice? I realize `forever` can be used too but still do you have to kill the old node process and start a new one every time I update my app? Can the upgrade be more seamless without killing the Node process?