A complete guide to install Meteor App Telescope on Your Own Server

In this tutorial I’m going to give you detailed instructions on how to deploy Telescope on your own server running Centos.

I’m doing this on a  virtual machine on my server, the same procedure applies to any server like Amazon EC2, Heroku or any dedicated server running centos.

At the end of this tutorial you will be running telescope on port 3000 with nginx as proxy.

List of things we will cover in this tutorial

  1. Install node.js
  2. Install mongodb
  3. Install meteor
  4. Install meteorite
  5. Install telescope
  6. Install nginx

Before we start, lets update the system and make sure we have all the development libraries. Run the following commands as root

yum update
yum groupinstall "Development Tools"

Installing node.js  and NPM on Centos

Run the following commands. Make takes time, you might wanna get some coffee :)


wget http://nodejs.org/dist/v0.10.23/node-v0.10.23.tar.gz
tar xvfz node-v0.10.23.tar.gz
cd node-v0.10.23
./configure
make
sudo make install

You don’t have to install NPM sperately, it’s bundled with the node.

If you get “virtual memory exhausted: Cannot allocate memory” error, try rebooting the system.

Note: You might be tempted to get the latest code from git and install it, but for some reason beyond my understanding at this time, it doesn’t work.
It throws some error related to fibers package.
Error: “pre” versions of node cannot be installed, use –nodedir flag instead

Install MongoDB

Create a /etc/yum.repos.d/mongodb.repo file to hold the following configuration information for the MongoDB repository:

If you are running a 64-bit system, use the following configuration:

[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1

If you are running a 32-bit system, which is not recommended for production deployments, use the following configuration:

[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686/
gpgcheck=0
enabled=1

Issue the following command (as root or with sudo) to install the latest stable version of MongoDB and the associated tools:

yum install mongo-10gen mongo-10gen-server

Install meteor

Installing meteor is very simple, just run the following command

curl https://install.meteor.com | /bin/sh

install meteorite

npm install -g meteorite

ref: http://docs.meteor.com/

Install Telescope

git clone https://github.com/SachaG/Telescope.git
cd Telescope
mrt bundle ~/bundle.tgz

Last command bundles everything we need to run the app and saves it in your home directory.

Before we run the app, we have to reinstall fibers


cd ~/bundle/programs/server
rm -f -r node_modules/fibers
npm install fibers

Now lets start telescope

PORT=3000 MONGO_URL=mongodb://localhost:27017/myapp_db ROOT_URL=http://myappurl.com/ node bundle/main.js

You can change the port to what ever you want, 80 if you do not want to use a proxy server.

ref: https://github.com/SachaG/Telescope

Using NGINX as proxy for Telescope Meteor app

open nginx configuration file, In Centos it’s located at /etc/nginx/nginx.conf

and add this to server section of the file and restart nginx /etc/init.d/nginx restart

location / {
	proxy_pass	http://localhost:3000;
	proxy_set_header	Connection "";
	proxy_set_header	Host	$host;
	proxy_set_header	X-Real-IP	$remote_addr;
	proxy_set_header	X-Forwarded-For $proxy_add_x_forwarded_for;
}

Having to start the Telescope app manually when ever the system reboots is not cool, lets add it to system startup. We will use upstart for this.

Create a file called my_app.conf at /etc/init/ and add the following content to it.

start on runlevel [2345]
stop on runlevel [06]
respawn
respawn limit 10 5
script	
    APP_DIR=/absolute/url/to/telescope/bundle
    LOG_FILE=/var/log/amyapp_log
    export PORT=3000
    export MONGO_URL=mongodb://localhost:27017/myapp_db
    export ROOT_URL=http://my_app_url/
    /usr/local/bin/node "$APP_DIR/main.js" 2>&1 >> $LOG_FILE
end script

Are all the required programs in startup list? Lets check if mongodb and nginx are in system startup, if not lets add them.

Check it with the following command

sudo /sbin/chkconfig --list

If they are not, add them with the following command

sudo /sbin/chkconfig mongod on
sudo /sbin/chkconfig nginx on

It’s not optimal to serve static files through node, I tried to serve them with nginx but wasn’t successful. I will update the post, once I find the answer.

You should install phantomjs to make your app crawlable/searchable.

Installing Phantomjs

wget https://phantomjs.googlecode.com/files/phantomjs-1.9.2-linux-x86_64.tar.bz2
tar xvf phantomjs-1.9.2-linux-x86_64.tar.bz2
cp phantomjs-1.9.2-linux-x86_64/bin/phantomjs /usr/local/bin

You can get the latest and relevant download links from phantomjs downloads page.
If you face any problems during phatomjs installation, try this tutorial

Though the entire process takes less than 10 minutes now ( excluding the compile time of node ), It took me more than 2 days to figure everything out. I hope this tutorial tutorial saves your time.

If you find all this complicated but want to build a site with telescope, I’m available for hire :). Shouth News is the first site I built with telescope

Tagged with 

5 thoughts on “A complete guide to install Meteor App Telescope on Your Own Server

  1. This was really helpful. It got me pretty far and it gave me a much better understanding to how to deploy the Telescope app.

  2. This is excellent. I have tried to follow your instructions to deploy in a DigitalOcean droplet. However, I don’t seem to be able to start telescope. When I enter into terminal:

    PORT=3000 MONGO_URL=mongodb://localhost:27017/myapp_db ROOT_URL=http://myappurl.com/ node bundle/main.js

    I get:

    module.js:340
    throw err;
    ^
    Error: Cannot find module ‘/Telescope/bundle/main.js’

    Is it because I should replace “myappurl.com/” with my droplet’s ip? Or is there something elee I’m missing?

  3. please help. I have this error. Some blogs say that is because meteor last version don’t support some mongodb confs used in telescope:

    ROOT_URL=http://ec2-54-201-32-51.us-west-2.compute.amazonaws.com node bundle/main.js

    /root/bundle/programs/server/boot.js:185
    }).run();
    ^
    Error: MONGO_URL must be set in environment
    at Object. (packages/mongo-livedata/remote_collection_driver.js:33)
    at Object.defaultRemoteCollectionDriver (packages/underscore/underscore.js:724)
    at new Meteor.Collection (packages/mongo-livedata/collection.js:66)
    at Package (packages/service-configuration/service_configuration_common.js:8)
    at packages/service-configuration.js:43:4
    at packages/service-configuration.js:52:3
    at /root/bundle/programs/server/boot.js:154:10
    at Array.forEach (native)
    at Function._.each._.forEach (/root/bundle/programs/server/node_modules/underscore/underscore.js:79:11)
    at /root/bundle/programs/server/boot.js:81:5

Leave a Reply