Back To The Main Support Page
Deploying Your Application to Slingshot using Capistrano
What is Capistrano?
"Capistrano is a standalone utility that can also integrate nicely with Rails. You simply provide Capistrano with a deployment “recipe” that describes your various servers and their roles, and voila! You magically have single-command deployment. It even allows you to roll a bad version out of production and revert back to the previous release." -- Capistrano: Automating Application Deployment
What do you need to use Capistrano?
- The Capistrano gem installed on your local development environment
- A Rails Application under subversion control
- A Customized Slingshot Hosting deploy.rb file (see below)
I'm ready, how do I deploy?
First, install capistrano and capistrano-ize your application, according to the instructions on Capistrano: Automating Application Deployment. See the section on "Installing Capistrano"
In a nutshell, you'll do:
linux/ Mac OS X:sudo gem install capistrano
gem install capistrano
You may be prompted to install dependencies (net-ssh, net-sftp, and needle) if it asks, just say yes.
Capistrano-ize your application:
linux / Mac OS X:cap -A /path/to/application
Now, depending on how your server is configured, you can either deploy using externally managed fastCGIs with our custom scripts for restarting, or using mongrel_cluster.
How do I setup lighttpd with externally managed fastCGIs?
We are no longer using lighttpd setups in favor of mongrel/mongrel_cluster with Apache mod_proxy_balancer. If you still want to know, go here.
How do I setup Apache 2.1+ with mod_proxy_balancer and mongrel_cluster?
All you need to do is download our custom apache2_2_mongrel_deploy.rb file and replace it with your current deploy.rb in your config directory.
wget http://www.slingshothosting.com/files/apache2_2_mongrel_deploy.rb /path/to/application/config/deploy.rb
curl -O http://www.slingshothosting.com/files/apache2_2_mongrel_deploy.rb /path/to/application/config/deploy.rb
Open up the file in your favorite editor. We like textmate:
mate /path/to/application/config/deploy.rb
Change the following lines to suit your needs:
set :application, "your_application_name" set :user, "your_username" # leave blank to be prompted set :password, "your_password" # leave blank to be prompted set :svn_username, "your_username" role :web, "yourserver.slingshothosting.com" # could also be your FQDN role :app, "yourserver.slingshothosting.com" role :db, "yourserver.slingshothosting.com", :primary => true set :server_name, "yourserver.com"
You can alter other settings, but be aware that we prefer convention over configuration, and as it stands, Slingshot Hosting servers are ready for your application.
How do I start using capistrano?
You're ready to setup your directories:
rake remote:setup
rake remote:exec ACTION="setup"
Now, check in any changes you've made, be sure to add the files we've added:
svn add config/deploy.rb deploy svn commit --message "added Slingshot hosting capistrano to my app"
You're ready to deploy:
rake remote:cold_deploy
A cold deploy sets up your server from scratch ( a cold start from nothing). Once you've done this, you can continue developing and deploy to your server using:
rake remote:deploy
rake remote:deploy_with_migrations
If you're like us, you don't like waiting for a full checkout/export of your entire application every time you deploy, so if you're making small updates, use:
rake remote:update_code
And optionally, if you change application code (require application server restarts)
rake remote:restart
If you encounter any errors in your application, you can always roll back to a previous version. Simply execute:
rake rollback
Let us know if you have any questions, problems, or suggestions!