Category Archives: Server Administration – Deployment

Facebook application – deploying on the Cloud with Heroku.

Recently, Heroku announced a partnership with Facebook. Heroku is a famous [and my favorite] Platform as a Service for Ruby Apps and recently it launched a new stack that also supports java and python.
Facebook applications were always needed be scale-ready due to the network effect that they rely on. A successful Facebook application can literrally double it’s audience every day while it spreads over the huge user base of facebook.

This fact has developed a trend where facebook applications’ teams look for cloud solutions when deploying even small apps.

Facebook, listening to this trend, launched an automated way to host your app on cloud by integrating. Now when a facebook developer Creates a new app, in the first screen with all the basic options (app name, urls etc) there is a new option called “Cloud Services”

There you can select to host your facebook application on Heroku Cloud Service and see the following screens

Heroku Cloud Services - Integrating Facebook popup

Then you can select the stack (programming language) of your application. Heroku will spawn a process which will automatically build a new initial facebook application in the language specified. The app will have all the basics features, meaning authenticating from facebook, asking and using some basic permissions and rendering a welcome page featuring facebook’s api.

Heroku Cloud Services - Integrating Facebook - Choosing Stack / Language

In my case, I chose ruby and thus heroku started a new Sinatra Application, bundled with all the basic gems

Heroku - Facebook Application - Ruby - Sinatra

source :gemcutter
 
gem "sinatra"
gem "mogli"
gem "json"
gem "httparty"
gem "thin"

 

The magic part is that now heroku and facebook have complete the whole process for you and the exact application url that is spawned to start on heroku is added in the specified fields of the app configuration page.

Heroku Cloud Services - Integrating Facebook

To go on and customize your brand new application, just wait for the email from the heroku team that gives you a git repository. You clone, edit and

push heroku master

to deploy your app.

Heroku: How to sync your production database with your development environment.

Apart from heroku db:pull (uses taps and imports from psql to any local sql database) there is a faster way to download and import the production data to your local server.

1. Generate a dump file of the production database using

heroku pgbackups:capture

This will actually run the pg_dump script on the production server
2. List the backups

heroku pagbackups

3. Get the download-able url of the latest backup listed

heroku pgbackups {lates_backup_name}:url

4. Download the file using the returned url.

Postgresql can use the files comming from the pg_dump with the usage of pg_restore.

Now try this

pg_restore --verbose --clean --no-acl --no-owner -h 127.0.0.1 -U savvasmsc -d sweetlifer_development ~/Downloads/b019.dump