PDA

View Full Version : Ruby on Rails Deployment on Bluehost



graffxguy
05-09-2008, 08:56 AM
Hey all,
I'm trying to find some resources beyond the limited documentation provided by bluehost on how to deploy to bluehost.

They don't mention anything about Capistrano and that's what I want to use to deploy since it's so automated.

My problem is figuring out how to get it all setup for a shared server like bluehost.

Are there any blogs out there or screencasts that show you how to do this?

skraelling
06-14-2008, 01:19 PM
I just went through the process of setting up capistrano deployment on bluehost. There were several time consuming hurdles, largely related to the fact that I was unaware of the fact that bluehost blocks outgoing ports such as port 22 - took a while to figure out why the svn commands were failing!



Here is by deploy.rb file which I ended up using:
<CODE>
#name of the application used to create the directory on the production server
set :application, "APPLICATION_NAME"


##########
#source control / svn repository parameters
##########
set :scm_host, "SVN.REPOSITORY_HOST.COM"
set :scm_username, "SVN_USERNAME"
set :scm_password, "SVN_PASSWORD"

set :repository, "http://#{scm_host}/SVN/"

# We want subversion to "export", so that it won't pull all the .svn files.
set :deploy_via, :export


##########
#production server configuration
##########
set :domain, "PRODUCTION_SERVER_DOMAIN.COM"

#the bluehost user name
set :user, "BLUEHOST_USERNAME"

set :scm_command, "/home/#{user}/bin/svn"
set :local_scm_command, :default

#don't use the sudo command to execute commands
set :use_sudo, false

#what directory to deploy to
set :deploy_to, "/home/#{user}/rails/#{application}"



##########
# roles
##########
role :app, "#{domain}"
role :web, "#{domain}"
role :db, "#{domain}", :primary => true


##########
# TASKS
# ================================================== ===========================
# Define tasks that run on all (or only some) of the machines. You can specify
# a role (or set of roles) that each task should be executed on. You can also
# narrow the set of servers to a subset of a role by specifying options, which
# must match the options given for the servers to select (like :primary => true)
##########

# This overwrites the original task for our purposes
desc <<-DESC
A macro-task that updates the code, fixes the symlink, added the symlink
to the shared uploads folder. Finally takes a snapshot of the db.
DESC
deploy.task :default do
transaction do
update_code
symlink
end
end


##########
# Bluehost specific
# (since you can't restart the web server on shared servers
# redefine deploy:start, deploy:stop, and deploy:restart to do nothing
##########
namespace :deploy do
task :restart do
# run "mongrel_rails cluster::restart -C #{mongrel_config}"
end

task :start do
# run "mongrel_rails cluster::start -C #{mongrel_config}"
end

task :stop do
# run "mongrel_rails cluster::stop -C #{mongrel_config}"
end
end
</CODE>