There has been some interest expressed here and on Twitter for a description of the process of moving an application from the free meteor.com to my own server. I run my web applications (such as this blog) on Webfaction, which gives a lot of flexibility for setting up a number of different hosted services. I won’t say each step below is easy and as straightforward as it sounds, so feel free to add your difficulties to the comments below, and I’ll elaborate. Having the steps in one place will hopefully be as useful for you as it likely will be for me.
Note: Steps 1 – 3 in the list below are just for downloading data you may have collected in an online application onto your computer. If you don’t care about the online data, you can skip down to step 4.
- I installed Mongo on my local machine from http://www.mongo.org
- In a terminal on my local machine, I entered
meteor mongo --url my-app.meteor.comto get the username, password, url, port, and database name from the *.meteor.com website. The result is a URL that contains the information you will need for the next step: (username:password@url:port/databasename)
- save the data onto my local computer using
mongodump --host hostname:port --db databasename -u username -p password -o ~/Desktopwhere the information from the last step replaces the username, password, etc.
- To create a packaged version of the app that runs on my computer, go to the Meteor project directory, and type
meteor build --architecture os.linux.x86_64 ./. This assumes that the server that will be running your project is a Linux machine…but this assumption is probably a good one for most hosting services.
- Create a free account on mLab (http://www.mlab.com). The free account gives you 500 MB of space for databases. For comparison, the total size of my most-used application is only 2.7 MB. I think you’ll have enough space. The important thing to get, once you have a database set up, is called the URI. If you create a database, there is a box at the top of the page that gives you information that looks like this:
mongodb://which you will need in the next step.
- I learned the Webfaction specific steps from reading this page, though you won’t need to do the Mongo steps if you are using mLab as I am. On the Webfaction server, you must install node. You can do this by following the steps here. You must also create a custom WebSockets application. This will give you a port number that you will need in the step below where local variables are set.
- Again, this is a Webfaction specific instruction, but you need to attach the application to a domain/URL where your application will be accessed. Save this URL
- Once you have created the WebSockets app, upload the .tar file (from step 4) to the /webapps/web-sockets-application directory through ftp and unpack with
tar -xzf my-app.tar.gz
- Using the mLab information from step 5, the port number from step 6, and the location of the node application from step 6, you’ll need to fill in the appropriate parts of the commands below:
: @dsXXXXXXX.mlab.com:PORT/DATABASENAME?autoReconnect=true" # 2
- Almost there, folks. Inside the unpacked .tar directory (which will be called /bundle), enter the /bundle/programs/server/packages directory and run
- Go back to the /bundle directory and run
nohup node main.js. This terminal command will run a command continuously on the shell, even if you close the terminal.
- If you’ve made it this far, you might just have your Meteor app running on your own server.
I hope this helps you, but if you run into trouble, throw a comment below and I’ll see if I can help.