2011年9月28日 星期三

[筆記] Building social networking service with DIASPORA* on Heroku

_2011-09-29_12

Looks familiar? It's not Google+. It's DIASPORA. An open source project that implements a distributed social networking service. This project was announced on APRIL 24, 2010 (Just right after Facebook f8 2010 that is at APRIL 21). Alpha version was released at NOV 23, 2010 (two days before my birthday :P). 

According to this, Mark Zuckerbug also donated to it just because it's a cool idea.

It's built on Ruby on rails. So it might be not so difficult to port it to Heroku platform which is a nice RoR host (althrough it still took me some time). It might be easier than build from scratch on a Linux. 

I'm a newbie to these two (Heroku and DIASPORA). I'm also not familar with RoR. Here records steps I tried. 

create an application on heroku

First, you need to create an application on Heroku. There are several platform stack on Heroku. Cedar stack might be the newest and most powerful one. It supports several languages and frameworks. And It also makes it very easy to deploy RoR applications. 

You need to install heroku CLI before creating an application. And use "heroku login" to login to your heroku account.

Run the following command to create a new cedar application (assume application name is "mysocialy") --

heroku create --stack cedar mysocialy

After the application created, you'll have a url "http://mysocialy.herokuapp.com/" for your site. And a git repository: git@heroku.com:mysocialy.git

import source codes

Get DIASPORA* source codes from git hub:

git clone git://github.com/diaspora/diaspora.git

Get your source codes from Heroku git repository (you'll get an empty folder):

git clone git@heroku.com:mysocialy.git

If you have trouble to download from Heroku. Try to use "heroku keys:add" to add your ssh public key and try again.

Copy all files except ".git" folder from "diaspora" to "mysocialy".

Initial configuration

Make new configuration files from example.

cd config

mv application.yml.example application.yml  

mv database.yml.example database.yml

Edit application.yml. Make "pod_url" to your host. In this case:

pod_url: "http://mysocialy.herokuapp.com/"

Deploy codes

Add and commit files:

git add .

git commit -am 'initial import'

Push them to Heroku

git push origin master

The coolest thing that Heroku does is that it makes deploy codes so easy. All you need to do is to push your codes to its git repository. And it could also install all related modules for you (that is configured in Gemfile). Super easy.

Ok, I must admit that I lie a little bit. There might be some problems. After I pushes all codes to Heroku, I found there is an error that it couldn't find 'pg' (postgresSQL). Looks like it does not install into gem.

I found the answer that it might be problem with gem version. Need to run "bundle install" at local.  This will generate a new Gemfile.lock. Push this new file to Heroku might solve this problem

Ok, that's all?

Not sure if I missed anything (I might). Anyway, what I did is alive at "http://mysocialy.herokuapp.com/".

1 則留言:

  1. hello diaspora don't work for me there is my logs
    ****Diaspora does not know where your SSL-CA-Certificates file is.****

    回覆刪除