0

I was wondering, if I'm deploying a Meteor app to a VM, why can't I just install Meteor on the vm, and run my app with the meteor run command? The deployment section of the docs says to create a tarball bundle and deploy that to a server that has Node and MongoDB, but couldn't I just install Meteor on the server instead? And then setup my DNS entry to listen to port 3000... Why wouldn't this idea work?

nneonneo
  • 171,345
  • 36
  • 312
  • 383
Tyler Jones
  • 1,283
  • 4
  • 18
  • 38

2 Answers2

3

Your idea would work fine. However, I would just suggest that if you are going to use this you might as well run in in a more "production" type of environment. And it is pretty easy to setup.

On a high level here is what you will need:

  1. Need to install Node 0.8.x
  2. Need to install MongoDB
  3. Follow the directions here for deploying. These just got updated for Meteor 0.5.5 so just be aware of that.
  4. Need to install forever node.js package

To make my life easier I created a script to handle starting/stopping my meteor app. It will set everything up to use the full MongoDB:

#!/bin/bash

SUCCESS=0
FAILURE=1

if [ $# -ne 1 ]
then
  echo "Usage: start|stop|restart"
  exit $FAILURE
fi

case "$1" in
    start )
        export MONGO_URL=mongodb://localhost:27017/<name of the database>
        export PORT=3000
        export ROOT_URL=http://yourhostname.com:3000
        forever start bundle/main.js 
        ;;

    stop )
        forever stop bundle/main.js
        ;;

    restart )
        forever restart bundle/main.js
        ;;

esac
shinank
  • 607
  • 7
  • 14
  • I guess my question is, what's the difference between doing all of this, vs just installing meteor on the server? Is there some advantage to doing things the way you've described here? – Tyler Jones Feb 14 '13 at 14:48
  • Running just Meteor is more like a development mode. Everything is there to help you get up and running quickly for development. I'm not sure if Meteor runs a full blown MongoDB on the server side so that might be one reason why. Furthermore, if you wanted to have more control over your MongoDB server or scale it out it is well documented on the standalone MongoDB. I'm not sure that if you wanted more control of the MongoDB that runs with Meteor that you would be able to use the resources already available for the stand alone MongoDB. – shinank Feb 14 '13 at 15:16
  • In a nutshell, if you know you never will want to scale your application, if you dont care to learn more about node.js or MongoDB then running just Meteor as your production server should be ok. If think you might ever want to scale your application or learn some of the other tools that Meteor uses then you might as well bite the bullet and start learning those tools now. – shinank Feb 14 '13 at 15:18
  • I realized another reason you DON'T wanna just install meteor in production: doing it like this means you're in "developer" mode and therefore your js files and template files are not minified/compressed. Creating a bundle and deploying that minifies and compresses everything nicely. – Tyler Jones Feb 20 '13 at 13:56
  • Cool. That is another very good reason. This might be helpful to you too I just found it a few days ago. My script will let you start an app and keep it running. However, I wanted to create a service for it. I havent tried this myself but if you are going this route it might be useful. http://www.exratione.com/2011/07/running-a-nodejs-server-as-a-service-using-forever/ – shinank Feb 20 '13 at 14:04
0

You could run your deployment within the VM on just regular installed Meteor.

Think of it like running a rails app with the built-in development server. Tough in terms of Meteor, the bundled version should be no different from a development version. The bundle you create ensures that all the necessary dependencies are bundled with it as well.

A quote from the meteor docs about meteor bundle:

This command will generate a fully-contained Node.js application in the form of a tarball. To run this application, you need to provide Node.js 0.8 and a MongoDB server. You can then run the application by invoking node, specifying the HTTP port for the application to listen on, and the MongoDB endpoint. If you don't already have a MongoDB server, we can recommend our friends at MongoHQ.

$ PORT=3000 MONGO_URL=mongodb://localhost:27017/myapp node bundle/main.js

Other packages may require other environment variables (for example, the email package requires a MAIL_URL environment variable).

Well i never changed the underlying database to a dedicated MongoDB server with the development version, but i think that should be possible by just setting the mentioned environment variables.

P.S.:

You wrote:

And then setup my DNS entry to listen to port 3000...

You'll have a hard time setting a port with a DNS entry...

Community
  • 1
  • 1
waeltken
  • 127
  • 1
  • 6
  • So, you're saying there's no reason to NOT setup my VM by just installing meteor? The doc section you posted is why I thought the meteor team was saying we shouldn't setup our server by just installing meteor... – Tyler Jones Feb 14 '13 at 14:06