Catalog / Capistrano Cheat Sheet
Capistrano Cheat Sheet
A quick reference guide for Capistrano, a remote server automation and deployment tool written in Ruby. This cheat sheet covers essential commands, configuration options, and deployment strategies.
Core Concepts & Setup
Installation
Install Capistrano gem:
|
Add to your project’s Gemfile:
Then run |
Initialize Capistrano in your project:
This creates |
Key Configuration Files
|
Loads Capistrano’s tasks and recipes. Require other capistrano plugins here. |
|
Main configuration file for settings applicable across all environments (staging, production, etc.). |
|
Environment-specific settings (e.g., server addresses, user roles) for staging, production, etc. |
Basic Configuration Settings
|
|
|
|
|
|
Common Capistrano Commands
Deployment Commands
|
|
|
|
|
Server Management
|
|
|
|
Utility Commands
|
|
|
Advanced Configuration
Hooks
Hooks allow you to run custom tasks at specific points during the deployment process. Common hooks include:
|
Example: Run a task before
|
Custom Tasks
Define custom tasks in
|
Roles
|
Defines web servers. |
|
Defines application servers. |
|
Defines the database server (marked as primary). |
SSH Configuration
|
Tips and Troubleshooting
Common Issues
Permission Denied: Ensure the deploy user has necessary permissions on the server (e.g., ownership of the deployment directory). |
SSH Key Issues: Verify the SSH key is added to the server’s |
Linked Files/Directories: Double-check that linked files and directories exist in the |
Branch not found: Verify the specified branch exists in the repository. |
Debugging
Use |
Check server logs in |
Best Practices
Use a dedicated deploy user on the server with limited privileges. |
Keep your |
Test your deployment process in a staging environment before deploying to production. |
Automate database backups as part of your deployment process. |