Let’s go serverless.. getting started

This is a post that shows how to install and configure serverless framework for google cloud platform.

serverless icon

What do you mean serverless?…

For those of you who don’t know, serverless architecture is an architecture in which you get a dynamic allocation of machine resources and charged for the actual amount of resources consumed by an application, rather than on pre-purchased units of capacity. So, if you have some highly scalable short tasks this should be perfect, but if you have some very frequent and long-running tasks, this type of an architecture might not the best feat.

Serverless architecture doesn’t imply running application without an actual server-side, but won’t need to host or manage it by your self. Many people will also consider BaaS(Backend as a Service) a serverless solution, but we won’t talk about that here, instead, we are going to dive into FaaS(Function as a Service).

What do I need?(requirements)

We will work with npm and Node.js. If you don’t know what it is, get familiar and to install here. I will use the Serverless framework here with Google Cloud Function as this is what I have at my disposal right now.(Although we do it here with Google Cloud, all this can be easily adapted to run on AWS, Azure or Bluemix) If you don’t have Google Cloud Account, you can get a free trial for a year here.

The Serverless Framework

Although we can just use Google Cloud Functions directly, we will use here Serverless Framework for few reasons:

  1. it abstracts out a lot of  hassle with building and deployment(also it will help us with our CI)
  2. it adds  some convenient structure to the project

We will get to the former in next part but for now, let’s talk about the project structure. If you dealt with microservices architecture before, then you are familiar with the concept of service. If you unfamiliar, services is a separate application unit organized around capabilities, e.g., user interface front-end, recommendation, logistics, billing, etc. Ideally, it should be independent and easily replaceable. In Serverless Framework your functions are also organized in services. So if want to build our articles sharing system, we will need three services: users service, articles service, and sharing service.


Follow these instructions on setting up your Google Cloud credentials

Create your first service

Install the dependencies by running  npm install from your my-service folder, deploy it to your cloud using  serverless deploy command.

Android emulator fails to start after an update

The problem:

A week ago, after some update(not really sure which one), I faced a very frustrating issue: I could not start my android emulator(AVD) anymore. It failed with a not very informative error:

I say that it is not very  informative because it talks about glx and dri, while the actual problem is with libstdc++.so.6 which provided with the Android SDK. So in order to make the Android Emulator work again, we will have tor replace it with the system default libstdc++.so.6

The solution( fixing android emulator)

This fix android emulator assumes that you have android sdk installed at ~/Android/Sdk . This is the default path when installing Android Studio on Linux. If you have it under different directory please replace ~/Android/Sdk with the path to your sdk in the first line.

And that is all, folks. Android Emulator should start properly.

Update 1:

for newer versions of android sdk libstdc was moved inside the emulator folder, so updated path goes like this:

Update 2:

If you cannot see libstdc++.so.6 in any of above paths, just make a search for it in your android sdk folder and adjust the path accordingly.

Disclaimer: based on tobias.preuss  answer.

How to install your own parse-server on OpenShift

UPDATE October 2017: As of today, OpenShift 2 is officially reached its end of life and is shut down rendering this guide irrelevant. I will keep it here for historical purposes.

Please note that this guide was for version 2 of OpenShift cloud platform. parse-server-example supports OpenShift 3 platform out of the box, so there is no need for any external guide.

TL;DR just take me to the instructions

parse-openshiftFew months ago I was consulting a start-up called AbiliSense on their cloud solution. They build this amazing mobile app for people with hearing disabilities. After understanding their service needs we decided to go with Parse BaaS solution, and it was all good until the dramatic Parse Announcement  about the retirement of their services. So there was a bit of frustration … But then we realized that parse-server gone open-sourced, so I said: You know what, this is even better! We will still use it as before, but now we will also own it!
Most of the functionality work out of the box, including cloud code. And also push notifications are implemented now as well.
There are guides on how to run it on many different cloud platforms. But not for OpenShift. Installing parse-server on OpenShift is a bit tricky, because of an outdated stock node.js and MongoDB cartridges. Luckily, this guy: icflorescu already created custom  node.js and MongoDB cartridges, that are up to date. So we are going to use these custom cartridges with more recent versions. Some people also have reported running into issues because of an old GCC version, but it seems that now parse-server does not rely on any native modules that require recent GCC version, so there should be no problem here. I tested it personally and it worked like a charm.

So let’s dive in, and see how you can run your self-hosted parse-server on OpenShift:

With Deploy to OpenShift button:

Deploy parse-server to OpenShift

IMPORTANT: after that follow the instructions in step #4 of web console steps to configure you APP_ID and MASTER_KEY

With OpenShift Client Tools(RHC):

First Installing the Client Tools (RHC), if you don’t have it already.

Using a web console

  1. Go to Choose a type of application in your OpenShift Online account, paste this URL
    into “Code Anything” textbox at the bottom of the page and click “Next”.
  2. Set your public URL, paste a modified for OpenShift parse-server git repo URL: https://github.com/antt001/parse-server-example into “Source Code” textbox and click “Create Application”.
  3. Add custom MongoDB cartridge to your new OpenShift application, go to “See the list of cartridges you can add”, paste this URL http://cartreflect-claytondev.rhcloud.com/github/icflorescu/openshift-cartridge-mongodb into “Install your own cartridge” textbox at the bottom of the page and click “Next”.
    1. If you use rhc, run the following command to set up you Parse APP_ID and MASTER_KEY

      replace myAppId and myMasterKey with your actual app id and master key
    2. If you don’t – then clone your OpenShift application repository with git using “Source Code” link from the application details in web console, and modify “appId” and “masterKey” values in index.js file

      replace myAppId and myMasterKey with your actual app id and master key, commit and push you changes to remote.

Live long and prosper, and enjoy you own parse-server on OpenShift.

Update 1:

This is an all-in-one solution, where you have your node.js server and MongoDB running on the same machine. This is good for development, testing or small-scale production(one small gear can handle around 60 requests per second, which is twice as much as Parse.com free tier). This is not a scalable solution. If you want a solution for a large scale production you will need to run a MongoDB cluster(don’t do it, unless you are an expert in MongoDB clusters) or use external services like mLab to do it for you. I will write a detailed guide for a scalable solution with mLab.


Debian jessie failing update with insserv rejected the script header

Few days ago my Debian jessie package update(e.g. apt-get upgrade) start failing with following message:

I was able to fix the problem by using solution described at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=589238 and https://wiki.debian.org/LSBInitScripts

Long story short:
When I tried

I saw that dependency information is missing in smfpd init script. The solution was to add following:



and that was it. keep in mind that you might have to run also :

if update still fails.

How to install upstream kernel on debian testing

Sometimes you need to install the latest and greatest kernel image on you Debian testing installation. In most cases that is to support some newer hardware piece, or to get latest features. You have two choices here: You can either compile it from sources, or you can just take it from the Debian experimental repository. There are plenty guides online on how to build you kernel from sources, so we won’t go into it. Instead i will explain how you can grab a ready build from Debian and save all this time configuring and compiling kernel source code.

This is how you can add experimental repository preferences to you Debian testing  installation, install upstream kernel and keep it up to date with apt:

  1. First let’s add preferences for experimental repository, so it would be used only when specified manually
  2. Then lets add an experimental repo to sources list
  3. update packages db
  4. search for kernel of you choice. In my case i wanted linux-image-4.4.0-trunk-arm64

    i also needed firmware-realtek, firmware-linux-nonfree and intel-microcode for hardware compatibility since i use intel core
  5. than just install every thing from experemental repo
  6. Live long and prosper


How to install Android ADT Bundle with Eclipse on Debian x86_64

This is a very old post and you probably should not bee reading this, because it is deprecated. But if you insist, suit yourself.
Due to missing 32 bit libraries installation eclipse adt bundle fails to run on x64 Debian installation. This is how you can fix this:

How to install Android ADT Bundle dependencies:
  1. Download ADT Bundle from d.android.com
  2. Open terminal and run as root:
  3. open ‘Main Menu’ application and create menu item for ~/adt-bundle-linux-x86_64-20130219/eclipse/eclipse

If you cannot find ‘Main Menu’ in your applications – install alacarte package:



How to disable Google Play Magazines on Note II(no root)

If you, like me, live in country that is unsupported by Google Play Magazines, than you don’t need this app on your phone.
But here is the tricky part:
I have updated my phone firmware with kies to 4.1.2
(I’m talking about Galaxy Note II GT-N7100 BTW, but you can apply this to any phone/firmware with similar problem)
Every thing was great until I noticed a battery drain. So I looked in battery usage statistics, and so there  Google Play Magazines eating my battery for 9 hours(active time). ‘I will just disable this app in application manager’, i thought to my self. But the app wasn’t there. WTF?! I checked the APK in  system/app: it was there. Application manager: no Magazines.

Had I rooted my phone, I would just delete the apk, but I didn’t.

So here is the solution if you find your self in this situation and don’t know what to do:

1. download Magazines.apk
2. enable ‘Settings->Security->Unknown sources’ on your phone
3. install the apk using file manager
4. go to ‘Settings->Application manager->All’ find Magazines and tap it
5. uninstall updates
6. disable

thats it. No root needed.