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
- Install node.js
- Install mongodb
- Install meteor
- Install meteorite
- Install telescope
- 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
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
tar xvf phantomjs-1.9.2-linux-x86_64.tar.bz2
cp phantomjs-1.9.2-linux-x86_64/bin/phantomjs /usr/local/bin
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
This was really helpful. It got me pretty far and it gave me a much better understanding to how to deploy the Telescope app.
Glad it helped 🙂
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?
CD to home directory and then run the command.
You should be one directory above bundle directory
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
Im facing a problem when I create the telescope folder. When I enter the mrt command, heres what happens….
Stand back while Meteorite does its thing
Done installing smart packages
Ok, everything’s ready. Here comes Meteor!
iron-router: updating npm dependencies — connect…
npm ERR! Error: EACCES, open ‘/Users/shwaytaj/.npm/inherits/2.0.1/package/package.json’
npm ERR! { [Error: EACCES, open ‘/Users/shwaytaj/.npm/inherits/2.0.1/package/package.json’]
npm ERR! errno: 3,
npm ERR! code: ‘EACCES’,
npm ERR! path: ‘/Users/shwaytaj/.npm/inherits/2.0.1/package/package.json’,
npm ERR! parent: ‘readable-stream’ }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 13.0.0
npm ERR! command “/Users/shwaytaj/.meteor/tools/cef2bcd356/bin/node” “/Users/shwaytaj/.meteor/tools/cef2bcd356/bin/npm” “install” “connect@2.9.0”
npm ERR! cwd /Users/shwaytaj/.meteorite/packages/iron-router/EventedMind/iron-router/05415a8891ea87a00fb1e2388585f2ca5a38e0da/.npm/package-new-123mpg4
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! path /Users/shwaytaj/.npm/inherits/2.0.1/package/package.json
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open ‘/Users/shwaytaj/.npm/inherits/2.0.1/package/package.json’
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/shwaytaj/.meteorite/packages/iron-router/EventedMind/iron-router/05415a8891ea87a00fb1e2388585f2ca5a38e0da/.npm/package-new-123mpg4/npm-debug.log
npm ERR! not ok code 0
mailchimp: updating npm dependencies — mailchimp…
npm ERR! Error: EACCES, mkdir ‘/Users/shwaytaj/.npm/request/2.39.0’
npm ERR! { [Error: EACCES, mkdir ‘/Users/shwaytaj/.npm/request/2.39.0’]
npm ERR! errno: 3,
npm ERR! code: ‘EACCES’,
npm ERR! path: ‘/Users/shwaytaj/.npm/request/2.39.0’,
npm ERR! parent: ‘mailchimp’ }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 13.0.0
npm ERR! command “/Users/shwaytaj/.meteor/tools/cef2bcd356/bin/node” “/Users/shwaytaj/.meteor/tools/cef2bcd356/bin/npm” “install” “mailchimp@1.0.3”
npm ERR! cwd /Users/shwaytaj/Telescope/packages/mailchimp/.npm/package-new-14y01me
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! path /Users/shwaytaj/.npm/request/2.39.0
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir ‘/Users/shwaytaj/.npm/request/2.39.0’
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/shwaytaj/Telescope/packages/mailchimp/.npm/package-new-14y01me/npm-debug.log
npm ERR! not ok code 0
fast-render: updating npm dependencies — connect…
npm ERR! Error: EACCES, open ‘/Users/shwaytaj/.npm/inherits/2.0.1/package/package.json’
npm ERR! { [Error: EACCES, open ‘/Users/shwaytaj/.npm/inherits/2.0.1/package/package.json’]
npm ERR! errno: 3,
npm ERR! code: ‘EACCES’,
npm ERR! path: ‘/Users/shwaytaj/.npm/inherits/2.0.1/package/package.json’,
npm ERR! parent: ‘readable-stream’ }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 13.0.0
npm ERR! command “/Users/shwaytaj/.meteor/tools/cef2bcd356/bin/node” “/Users/shwaytaj/.meteor/tools/cef2bcd356/bin/npm” “install” “connect@2.13.0”
npm ERR! cwd /Users/shwaytaj/.meteorite/packages/fast-render/arunoda/meteor-fast-render/149984b1aff3a5642a270aff9bd9006872c8302e/.npm/package-new-tbpvw
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! path /Users/shwaytaj/.npm/inherits/2.0.1/package/package.json
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open ‘/Users/shwaytaj/.npm/inherits/2.0.1/package/package.json’
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/shwaytaj/.meteorite/packages/fast-render/arunoda/meteor-fast-render/149984b1aff3a5642a270aff9bd9006872c8302e/.npm/package-new-tbpvw/npm-debug.log
npm ERR! not ok code 0
Errors prevented bundling:
While building package `iron-router`:
error: couldn’t install npm package
While building package `mailchimp`:
error: couldn’t install npm package
While building package `fast-render`:
error: couldn’t install npm package
/usr/local/lib/node_modules/meteorite/lib/command.js:41
throw “Command exited with ” + code + “/” + signal;
^
Command exited with 1/null
static-7:telescope shwaytaj$
Application has an error even after reinstalling fiber
and where does bundle/main.js suppose to come from?
Having a similar problem (i believe).
I followed the instructions no problem until I get to the part of “cd ~/bundle/programs/server” where I get the no such file or directory error. I tried looking for the “bundle/main.js” no such file. I’VE BEEN ON THIS FOR ALMOST A MONTH. Please HELP?
Got stuck on cd ~/bundle/programs/server; getting a “no such file or directory” error. I tried to look for it manually but no luck.
Would this work on Ubuntu 14.04?
I was sooo grateful when I found your step-by-step explanation. Thank yuo very much for your effort! But unfortunately I am stuck with an error as well. Can you help?
Stand back while Meteorite does its thing
Done installing smart packages
Ok, everything’s ready. Here comes Meteor!
/root/.meteor/packages/meteor-tool/.1.4.1_2.354htk++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/meteor-promise/promise_server.js:165
throw error;
^
Error: ENOENT: no such file or directory, open ‘/tmp/mt-5vosg1/os.json’
at Error (native)
/usr/local/lib/node_modules/meteorite/lib/command.js:41
throw “Command exited with ” + code + “/” + signal;
^
Command exited with 1/null