For production why should I "bundle" the meteor application and not just copy
the sources on the server use the "meteor" command?
Basically what is the difference between:
"meteor bundle app.tar.gz", then installing the right version of fibers and nodejs
and extracting the archive and starting with "node main.js" the app,
and copying the project sources on the server and just writing "meteor" to start
the app?
This won't be an exhaustive list, but here are some things that the meteor
command does:
- creates a local database
- watches on every dependent file in your app or in your packages
- sends every file separately and unminified to the client (this is super inefficient unless you are developing locally)
In contrast, bundling an app:
- does not create a local database
- does not spend CPU watching your files for changes
- creates two minified files (js and css) which is perfect for putting on a CDN or hosting from a reverse proxy. These are also efficient for clients to download and are highly cacheable.
In general, deploying shouldn't be a huge pain if you use a good set of scripts.
When using a bundle:
- It will not spawn meteor-mongo(Mongodb inside meteor)
- No hot reloads
- Meteor will not watch your files.
- You can leave/quit the server without killing your app.
- You can manage node processes smoothly by using pm2 or other similar npm packages.
- You can decide where to put your mongoDB and decide what port to use.
- You can connect to your mongodb remotely by not having to run your meteor app.
While using a copy or running meteor command in the project directory:
- You can't leave/quit the server while keeping the project running without using any screen multiplexers (e.g. tmux)
- You can only use meteor's assigned mongodb which is spawned in localhost:3001 -- if meteor is using port 3000.
- You are letting meteor to watch over file changes which uses CPU.
- When your app dies, your db dies. :)