Activities

January 2014
M T W T F S S
« Dec   Feb »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Elastic BeansTalk : Rails deployment using PostgreSQL back end.

Elastic BeanTalk is a cool,easily and scalable deployment tool for deploying any applications. This would be a simple administrative approach to scale up servers to N.. numbers. ie if you are working on a long term product type business, you can try this feature or you can use the application which will have short term live and expecting countless visitors.

Based on my experience, EB does have,

a. Using Route53
b. Loadbalencer
c. RDS database (optional)
d. EC2 platform
e. Autoscaling and Cloudwatch Alarm
f. Elastic Beantalk command line tools and Git

One of my specific project which I had worked was Rails with PostgreSQL backend, Beanstalk deployment for Rails with MySQL is fairly an easily. But the same did not work for PostgreSQL deployment.

Here are the screens which explains how to deploy a simply application which using Rails and PostgreSQL. Pls note you can only able to see a sample application is working fine and whenever you try to deploy it over “eb” command, the same will shows that’Failed” or RED status in environmental list form.

In EB platform, There is two catagories, ie first you need to create an Application and then create different environment (projects) in that Application,

EB-1

1

2

3

4

5

6

7

Once you launched the new environment, you can start deployment. Deployment will trigger from the developer end using “eb” API commands. You can download the EB API from here.
http://aws.amazon.com/code/6752709412171743. Now you need to verify that you Python version is above 2.7 version. If not, you should up-grade it,

3. How do I upgrade my python version

Python up-grdation is easy, But it may broken yum installer sometimes as I found on my CentOS Box.
So use source code to download and execute configure/make and make install.

Then you need to,

 #mv /usr/bin/python /usr/bin/python_bk
 #ln -s /usr/local/bin/python2.7 /usr/bin/python
 #[root@rc-134 Python-2.7.3]# python -V
Python 2.7.3

4. Installing EB commandline API tools

#wget https://s3.amazonaws.com/elasticbeanstalk/cli/AWS-ElasticBeanstalk-CLI-2.6.0.zip
#Create a symbolic link to bin directory from the EB downloader folder.
#ln -s /home/installation/AWS-ElasticBeanstalk-CLI-2.6.0/eb/linux/python2.7/eb /usr/bin/eb
#[test@rc-134 ~]$ eb init

Note: $eb init command will prompt you input,

a. Access key
b. Access ID
c. Region in which EB launched
d. Stack type ( I uses 64bit Amazon Linux 2013.09 running Ruby 1.9.3)
e. Application Name :
f. environment Name
g. RDS name ( do not create RDS as it was set already from the Amazon mgmt console)

5. How do I verify eb commandline was correctly configured.

[rahul@rc-127 ~]$ eb status
URL             : serveridoltestapp.elasticbeanstalk.com
Status          : Ready
Health          : Green
RDS Database: AWSEBRDSDatabase | aahxdsfdskuezi.cn0lfmewpatf.us-east-1.rds.amazonaws.com:5432
[rahul@rc-127 ~]$

6. Starting Deployment

Next you need to checkout your file from Git repository and execute “git aws.push” from the rails root folder itself. Now all the files from your folder will be deployed to EB server shortly.

Note: My Case “git aws.push” works perfectly and but I did not see the file deployed over the eb url provided.

Problems : The 64 bit Ruby AMI which bundle with EB setup does not have native postgres devel package loaded. You can see Elastic beanstalk deployment script at /opt/elasticbeanstalk/hooks/appdeploy on Rails server. After checking the script content of “pre” script folder, I found the script file “10_bundle_install.sh” which will be executing “bundle install”command from the application folder which was broken with an error “posgresql native extension is not found” So the next phase of deployment has been skipped and hence “ondeck” folder remains under “/var/app” folder. If it is a clean deployment, ondeck will be deleted up on build completion. I think EB-Rails deployment barely support MySQL.

Solution:
Log on the EB web server instance (you can see it on along with other server names list in AWS console and you can login in to using the key file that you chosen to setup instance) that install the posgresql package. #yum install postgresql-devel” and then deploy again.

 #yum install postgresql-devel

Now try a git aws.push again and you can see the new files were deployed on server successfully.

1 comment to Elastic BeansTalk : Rails deployment using PostgreSQL back end.

  • Dan

    Hi – This is a great article, thanks for publishing it. I think I’m having the problem which you managed to solve here, but when I try yum install postgresql-devel – I’m told I need to be root to carry it out – how did you manage root access?

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>