Guide: How to Deploy Meteor / Telescope on Centos

Deploying meteor or telescope can be tricky sometimes especially when it comes to centos support. Here are the steps I am following to deploy my meteor app.

Development Environment:

  • OSX

Production Environment:

  • Linode 1GB
  • Centos 7
  • Apache

Software Stack on production:

  • Mongo DB
  • Node.js 0.10.35
  • NodeJS “Forever” module to start application in the background

I am not using NGINX as most of the people suggest as I already have a lot of applications running on Apache.

Just make sure that all the development libraries are available:

 Install Node.js

Install MongoDB

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

For 64 bit:

For 32 bit:

And:

The server setup is done. Please don’t need that you don’t need to install meteor or telescope in your production environment.

Package your app

On your local (development) machine, go to your meteor / telescope app directory and enter the following command:

It will build a new directory in your app directory named “yourapp_prod” It contains the bundle of your app. Compress yourapp_prod and upload to your servers home directory.

Push app to server

Make sure the port is free. If it is not free, you can use 3000 instead of 8080. Uncompress the file in your server’s /home directory and try start your app in the following series of commands:

It might give the following error that I am not sure about:
/home/yourapp_prod/bundle/programs/server/node_modules/fibers/future.js:173
throw(ex);
^
Error: /home/yourapp_prod/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/build/Release/bcrypt_lib.node: invalid ELF header
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at bindings (/home/yourapp_prod/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/node_modules/bindings/bindings.js:74:15)
at Object.<anonymous> (/home/yourapp_prod/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/bcrypt.js:1:97)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

But there is a fix for that:

Let’s try to run the app again:

It should work ok now. Try to enter http://yourapp_domain:8080/ in the browser and it should work.

But the problem is if you quit your terminal, your app will stop working. You can install node “forever” module to run your app in the background.

But you don’t want to make it work with http://yourapp_domain:8080/, you want to make it work with http://yourapp_domain/

You can configure a reverse proxy in your apache configuration. In case of Centos 7, you need to create some file like /etc/httpd/conf.d/yourapp_domain.conf. The contents of the file will be something like:

In my case, the app is running at port 8080, you can change the port number accordingly.

Restart apache now and your are DONE.

If you want more support or want to hire me, feel free to write in comments on write me directly at ping@qasimzeeshan.com

Load masonry after all the images are loaded

The team decided to make the homepage of Biyixia.com like Pinterest or toptenreviews.com. Challenging, but thanks to the Masonry. Masonry was working absolutely fine on localhost but on the server it looks a bit messed up.

The reason was that on slow connections Masonry was being loaded before all images gets loaded in the browser so looked a bit messed up. So I loaded masonry in the following code:

And it worked like a charm. Here is the new biyixia.com homepage:

Screen Shot 2014-12-24 at 1.07.27 pm

Please feel free to share better solutions.

No package php-pecl-memcached available.

I was trying to install memcached on a centos 6.6 machine but when I run yum install php php-pecl-memcached, I was getting the error “No package php-pecl-memcached available.” I resolved it using the following method:

  • Open yum.conf that might be available at /etc/yum.conf
  • Find the line starting with exclude=
  • Remove “php” from that line. As it is preventing any package to install that was starting with “php”
  • Save the file yum.conf.

Now run the following command again:

It was ok.

 

Drupal: Managing translations in a multisite environment.

Currently, I have been working on a complex Drupal project with around 400 subdomains and half a million nodes. All the subdomains have same codebase. The product is in Chinese language and my real issue was to translate the strings from English to Chinese but the problem was that if a string is translated in one subdomain, it has to be translated to other 399 subdomains as well, so I decided to use the translation table of one (parent) domain on all other subdomains. So I just added the following lines to the settings.php of all 400 domains:

$databases['default']['default']['prefix'] = array(
'default' => 'mysite_',
'locales_target' => 'parent_db.mysite_',
'locales_source' => 'parent_db.mysite_',
);

“parent_db” is the database of the parent subdomain. Now if you change the translation of any subdomain, it will use the table of “parent_db” and will be changed in all 400 subdomains.

Working in China

My working span in China was short. I was hired by a startup named biyixia.com as lead software engineer. I was already working with them offshore but due to long documentation process, I had to wait too long to apply for the visa. Chinese work visa process needs at least two years of work experience and I was 4 years experienced by that time so it was not a big deal.

First couple of weeks are always the toughest ones in any new culture so mine were no different. It’s really hard to adapt the life style especially food. I was used to Pakistani style food but my team only consists of chinese guys so expecting them to prepare Pakistani food for me was a big no no. I was living in Changping district in Beijing and there is hardly any Pakistani restaurant but I discovered some Muslim(Xinqiang) restaurants in the neighborhood where I usually used to eat. Otherwise I mostly rely on vegetables.

The team was so cooperative, I am always very thankful to them. They never made me realize that I am away from my family. Every evening I used to go to the Beijing Electrical Engineering University nearby for a walk. It was awesome.

Beijing is mostly hated by expats due to its bad air. The air pollution is a big issue in almost every city in China. I am from Lahore and it’s pretty much polluted but believe me Beijing is tougher than that. I always user to check pm2.5 before I go out.

Hovering around in Beijing can be complex for new comers but it has excellent public transportation especially the subway. It works just like any other subway in the world. You can travel between any two terminals for just 2 RMB. On the weekends, we used to go to the Olympic park for jogging and after that we used to go to Chaoyang to enjoy Pakistani food at Khanbaba.

It is always recommended that you should live close to your workplace if you are an expat as Subway is so crowdy in the mornings.

Chinese society is a capitalist society and you will feel that. Most of the people just have one objective, earn as much money as they can. Beijing has a lot of people coming from different regions of China so living cost is very high i.e. 3000RMB per month for a one room apartment in Changping. So most of the young guys share apartment with others to reduce the living cost.

Overall I feel very lucky that I got the chance to live in Beijing and worked with wonderful people. China, I miss you.