Tag Archives: capistrano

Capistrano Deploy for Shared Hosting with GIT Repository

Would you like to deploy your Rails apps on a shared hosting account via Capistrano? I keep a couple of small projects on A Small Orange and since I update them so infrequently, I can never remember all the steps. Duh, that’s what Capistrano was made for. So I took a night and wrote the following deployment script. There are a couple of requirements:

  • Your project is in a GIT repository, local or remote.
  • The GIT repository only needs to be accessible from your local machine (ASO servers do not support GIT).
  • WARNING: running any part of this script will completely delete your /public_html directory!
  • You only need modify the first FOUR ‘set’ lines.

A shared/system_stopped directory will be created on the server, any files in here will be served when you do a ‘cap deploy:web:disable’. You can add a ‘system_stopped’ directory to your project and those files will automatically be copied into the shared directory.

This script works best if you start from the beginning as this is a new deployment as a couple of directories need to be created:

There are a few commented out lines that you may wish to uncomment. I tried to explain their use, so you may wish to read over each function.

Lest I repeat myself… WARNING: this will completely delete your /public_html directory! Make sure you have a backup before you run any function in this script.

I plan on adding a full db backup option (run before migrations, or at will) and a production.log rotation.

Posted in Rails. Tagged with , , .