Setup multistage deployment with Capistrano Passenger and SVN with Staging Development Production environments

When application needs to be set on different environment like staging and development question comes  how to manage cap deploy ?

Here are easy steps which will guide to setup and manage with SVN and Capistrano

Setup multistage deployment with Capistrano
1)    Install capistrano and capistrano multistage
2)    Capify your project
3)    Prepare the deploy / directory
4)    Create the deployment recipes

For my project i have created development and production environment. Name your stages whatever you want. but, never name one of your stages stage — it’s a reserved word. We Can name it “staging”.

1) Install capistrano and capistrano multistage

gem install capistrano –no-ri –no-rdoc
gem install capistrano-ext –no-ri –no-rdoc

2) Capify your project

capify you project with following command in project root folder

capify .

3) Prepare the deploy / directory

mkdir config/deploy
touch config/deploy/development.rb
touch config/deploy/production.rb

4) Create the deployment recipes

require ‘capistrano/ext/multistage’

set :stages, %w(development production)
set :default_stage, “development”
set :application, “application”

set :user, “username”
set :password, “password”

set :repository, “https://domain/svn/project/trunk”
set :scm, :subversion
set :scm_username, “repository_username”
set :scm_username, “repository_password”
set :deploy_via, :export

# deploy using “ssh-add”, then “cap deploy”
ssh_options[:forward_agent] = true
set :ssh_options, {:forward_agent => true}
set :use_sudo, false

# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end

task :install_configs
#perform specify operations like set path or other stuff here
end

task :restart, :roles => :app, :except => { :no_release => true } do
run “#{try_sudo} touch #{File.join(current_path,’tmp’,'restart.txt’)}”
end
end

after(‘deploy:update_code’, “deploy:cleanup”, ‘deploy:install_configs’)

 

Now it’s turn to set both files which we have created in config/deploy 1) development.rb  2) production.rb

Set your development.rb

server “development.domain.com”, :app, :web, :db, :primary => true
set :deploy_to, “/var/www/development.domain.com” #path where you want to deploy application on server
set :db_config, “database-development.yml”

namespace :perform do
task :install_configs
#perform specify operations like set path or other stuff here
end
end

after(“deploy”, “perform:install_configs”)

Set your production.rb

server “production.domain.com”, :app, :web, :db, :primary => true
set :deploy_to, “/var/www/production.domain.com” #path where you want to deploy application on server
set :db_config, “database-production.yml”

namespace :perform do
task :install_configs
#perform specify operations like set path or other stuff here
end
end

after(“deploy”, “perform:install_configs”)

 

Great, you are ready to deploy with both environments

When you deploy recipe with cap deploy it will start deploying default environment whatever is set, if you want to deploy specific for environment please run command cap “environment” deploy in our case cap production deploy .

All set with multistage Capistrano deployment with minimal configuration.Lot more for rails 3 and RVM configuration.

Tagged , , , , , ,

Experience with RhoMobile Framework (Cross Platform mobile application development using Ruby !)

Since last three months i been working with RhoMobile (Cross platform mobile development using Ruby).

As i came across it’s totally new domain for me, you need to understanding mobile device environment and behavior .

Major part while developing application with RhoMobile.

1) Ruby

2) Services for different functionality

3) Jqmobile / Jquery

4) Rhodes SDK

5) Cross platform SDKs (iPhone, Android, BB)

More details and installing guide for different platform available http://docs.rhomobile.com/

Tagged , , ,

Install Rabbitvcs in ubuntu

Manage SVN and GIT with GUI interface

Open Terminal

Step 1

sudo add-apt-repository ppa:rabbitvcs/ppa

Step 2

sudo apt-get update

Step 3

sudo apt-get install rabbitvcs-core

Step 4

Install nautilus,thunar,gedit

sudo apt-get install rabbitvcs-nautilus rabbitvcs-thunar rabbitvcs-gedit rabbitvcs-cli

Enjoy !

Tagged , , , , , , ,

Configure Mongodb with mViewer GUI interface in Ubuntu

Now a days mongodb is largely used, how to configure in ubuntu.

Follow steps :

1) add this line to your /etc/apt/sources.list
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

2) sudo apt-key adv –keyserver keyserver.ubuntu.com –recv 7F0CEB10

3) sudo apt-get update

4) sudo apt-get install mongodb-10gen

You are ready with mongodb , to check status service mongodb status.

Now install mViewer the Mongodb GUI interface.

1) Download mViewer from

https://github.com/Imaginea/mViewer

2) Now go to scripts folder and run start_mviewer.sh

3) Visit your localhost on 8080 port with no username and password if you have not set any(http://127.0.0.1:8080).

Now you are done with mongodb GUI interface.

Happy coding !

Tagged , , , , , , , ,

Setup Ubuntu machine for Ruby on Rails with RVM-Mysql-Git-Curl-Java-Sublime Text 2 or Scite

Configure brand new Ubuntu machine for Rails

Step 1 – Install RVM

Prerequisite for RVM sudo apt-get install curl git-core

Run command in terminal bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )

After installation update .bashrc is require

Replace [ -z "$PS1" ] && return with if [[ -n "$PS1" ]]; then

Also add following line of code at end of file

if [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi

fi

Run bash -l in terminal.

Now rvm notes you can see rvm is working !

Install following packages before installing ruby via RVM

sudo apt-get install build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline-dev libxml2-dev git-core subversion autoconf

After that rvm list known will display know ruby package choose your favorite !

Install using e.g rvm install 1.9.2

RVM Up and Running !!!!!!

Step 2 – Install Mysql

apt-get install mysql-server

Step 3 – Install GIT and Curl

Already installed as prerequisite.

Step 4 – Install Java

Can install Java using two methods

1st Method

sudo apt-cache search jdk
sudo apt-get install sun-java6-jdk sun-java6-jre

and set export JAVA_HOME=”/usr/lib/jvm/java-6-sun-1.6.0.06″ in your .bashrc file

2nd Method (Live installation)

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:sun-java-community-team/sun-java6
sudo apt-get update
sudo apt-get install sun-java6-jdk

System is ready with java, can check version with java –version in terminal

Step 5 – Install Sublime Text 2

Add Sublime Text 2 PPA using the following command

sudo add-apt-repository ppa:webupd8team/sublime-text-2

After run these commands in terminal
sudo apt-get update
sudo apt-get install sublime-text-2-beta

Step 6 – Install Scite

Run following command in terminal

sudo apt-get install scite

After this installations you are ready to enjoy rails ……

Tagged , , , , , , , , , , , , , , ,

Cross server files/direcories transfer with net/scp in ruby on rails

Some times while dealing with load balanced server we require to manage assets across servers, need to transfer data between load balanced
servers, workout with some gems and plugins finally found solution.

Following code snipts gives you brief on process.

require 'net/scp'
Net::SCP.start(@host, @host_user, :password => @password) do |scp|
scp.upload! source, dest, :recursive => true
end

stay connected ! RoR rules ……

Tagged , , , , , , ,

Display customize column name in ActiveRecord validation

There are number of ways to set custom column name ,

But i generally preferred following .

HUMANIZED_ATTRIBUTES = {:p_type=> "Advertise type", :body=>"Description"}

def self.human_attribute_name(attr)
HUMANIZED_ATTRIBUTES[attr.to_sym] || super
end

Now we can set custom column name , good to go.

Tagged , ,

Upgrade php centos

Remove the existing php version:

yum remove php php-*

Install php53 versions referring to the previously saved list. The names are the same except that instead of the prefix “php” you have “php53″:

yum install php53 php53-cli php53-devel php53-gd php53-mbstring php53-mysql php53-pdo php53-xml php53-xmlrpc php-pear

Tagged ,

Rails ActionMailer Setup with Yahoo SMTP setting

Code kept throwing”Errno::ECONNRESET (Connection reset by peer):’ error whenever I tried to connect to yahoo’s smtp server and send a message. It took me a while to figure what the problem was: Yahoo suggest me to use port 465; but the correct port number to use is 587!

So to save you couple of hours filled with frustration and hair pullings, here’s the action_mailer setup that works:

ActionMailer::Base.default_charset = "utf-8"
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.bizmail.yahoo.com",
:port => 587,
:domain => "www.your-domain.com",
:user_name => "username@your-domain.com",
:password => "some-password" ,
:enable_starttls_auto => true,
:authentication => :plain
}

Tagged , ,

How to install RMagick Gem on Linux/Ubuntu

How to install RMagick Gem on Linux/Ubuntu

While installing RMagick on Linux, if you are getting errors like this
“GraphicsMagick-config… no configure: error: Can’t install RMagick. Can’t find Magick-config or GraphicsMagick-config program. …”,
below is the solution for this error.

RMagick requires ImageMagick and which further requires loads of dependencies already available to get installed and work properly. I was figuring out of those all, and thank god got a quite simple and elegant way to do all that in just three commands.
First you will have to install imagemagick then libmagick9-dev and then finally you can install rmagick.


sudo apt-get install imagemagick
sudo apt-get install libmagick9-dev
sudo gem install rmagick

for debian
if ask for MagickCore library , search find / -name MagickCore.pc

yum install ImageMagick-devel
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig gem install rmagick

Source : http://expressica.com/2007/07/04/how-to-install-rmagick-gem-on-linuxubuntu/

Tagged , , , , ,
Follow

Get every new post delivered to your Inbox.