Capistrano
From A2Wiki
Capistrano
Getting started:
You'll need to install capistrano on your local machine:
gem install capistrano
And then deploy it to your local application directory:
cap --apply-to /path/to/my/app MyApplicationName
- The above command may not work depending on your version of capistrano. Newer versions require the following command ...
capify /path/to/my/app
You will need to alter your deploy.rb file in your /path_to_my_application/config/deploy.rb file
Config file issues:
A2hosting does not currently support svn over WebDAV. Some adjustments below are needed to work around this.
This is used as the name to define this capistrano instance:
set :application, "my_application"
These are the remote servers which will be connected to:
role :web, "my_domain_name.tld" role :app, "my_domain_name.tld" role :db, "my_domain_name.tld", :primary => true
Capistrano defaults to using SSH to log into the remote server, so we need to override the SSH port. Note, you must have small business or above account for shell access, unless you have ordered ala carte shell service. Please see http://www.a2hosting.com/web_hosting.php for more information.
ssh_options[:port] = 7822
Since most users will have different users on a2Hosting than on their local machine, they will need to set:
set :user, "your_username"
You need to supply the full path to your application.
set :deploy_to, "/home/your_username/your_application_root"
Capistrano really wants you to set up the repository from apache/WebDAV, so it can access it like so:
http://your_domain_name.tld/svn/your_application/trunk
However, that won't work at a2hosting. To make this work, we need to do two things: 1) use SSH instead of HTTP, and 2) create a custom protocol to use a2hosting's custom SSH port (7822 instead of 22).
To override the SSH port that Subversion uses, edit your ~/.subversion/config file. Under the [tunnels] section, add a new line containing a2hosting = ssh -p 7822. This enables the svn+a2hosting protocol referenced below. This also allows you to use the default svn+ssh protocol with other servers on port 22 for other projects (e.g. Rails plugins used in your project).
You'll also need to setup SSH keys on your account for passwordless login, or ssh-agent or you will have to enter your password a million times. See https://support.a2hosting.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=387 for details on how to set this up. The config below works, but will through some error messages.
set :repository, "svn+a2hosting://username@domain.tld/home/username/svn"
This defaults to 'true', but you will need to set it to 'false' so they can deploy onto a2Hosting.
set :use_sudo, false
The default is to use svn co. Using svn export will prevent the .svn directories from being pushed to production.
set :checkout, "export"
Please leave the quotes in send empty, unless you are running mongrel. If you are running mongrel, comment out the blank send, and use the send with mongrel_rails restart.
desc "Restart the app server"
task :restart, :roles => :app do
send(run_method, "")
#send(run_method, "cd #{current_path} && mongrel_rails restart")
end
Same deal here with mongrel.
desc "Stop the app server"
task :stop_app, :roles => :app do
send(run_method, "")
#send(run_method, "cd #{current_path} && mongrel_rails stop")
end
Here as well for the start portion.
desc "Start the app server"
task :start_app, :roles => :app do
send(run_method, "")
#send(run_method, "cd #{current_path} && mongrel_rails start -d -p #{app_port} -e #{app_env} < /dev/null >& /dev/null")
end
