Code Monkey home page Code Monkey logo

capistrano-recipes's Introduction

CapistranoRecipes

A gem with some capistrano recipes we use for our projects. This gem is not published to rubygems.

Installation

Add this line to your application's Gemfile:

gem 'capistrano-recipes', :git => 'https://github.com/auxilium/capistrano-recipes.git'

Require all or some recipes in your deploy.rb

# require all recipes
require 'capistrano-recipes/all'

# or include recipes one by one
# require 'capistrano-recipes/recipes/git'
# require 'capistrano-recipes/recipes/log'
# require 'capistrano-recipes/recipes/maintenance'
# require 'capistrano-recipes/recipes/nginx'
# require 'capistrano-recipes/recipes/postgresql'
# require 'capistrano-recipes/recipes/unicorn'
# require 'capistrano-recipes/recipes/uploads'

Setup your project

By default the recipes come with multistage support. This means you need to structure your application to have the different stage enviroments configured in config/deploy. See the example folder or the structure described below:

config/
  deploy/
    production.rb
    staging.rb
  deploy.rb

Recipes

Git

Commands
command description
git:check_revision checks if the HEAD is the same as the origin
default callbacks:

before: deploy, deploy:migrations and deploy:cold execute git:check_revision

Log's

Commands
command description
log defaults to cap log:rails
log:rails tails the rails log
log:sidekiq tails the sidekiq log (if present)
log:unicorn tails the unicorn log

Maintenance

Settings
  • :maintenance_path - default: "#{shared_path}/system/maintenance"
Commands
command description
maintenance:on turns on the maintenance page
maintenance:off turns off the maintenance page
maintenance:update_maintenance_page copies the maintenance page from public/maintenance
maintenance:check_maintenance_present checks if public/maintenance/index.html exists
default callbacks:

before: maintenance:on execute maintenance:check_maintenance_present
after: deploy:update_code execute maintenance:update_maintenance_page

Nginx

Settings
  • :include_www_alias - default: true
Commands
command description
nginx:setup Creates a new site on the nginx instance
nginx:start Starts the nginx service
nginx:stop Stops the nginx service
nginx:restart Restarts the nginx service
default callbacks:

after: deploy:setup execute nginx:setup

PostgreSQL

Settings
  • :postgresql_create_user - default: Asked by capistrano
  • :postgresql_user - default: Asked by capistrano
  • :postgresql_password - default: Asked by capistrano
  • :postgresql_database - default: "#{application}_#{stage}"
Commands
command description
postgresql:setup Creates a database.yml file
postgresql:create_database Creates the database and a user (unless it already exsists)
postgresql:create_symlink Symlink the database.yml file
postgresql:pull Pull the remote database and restore it on your local postgresql instance
default callbacks:

after: deploy:setup execute postgresql:create_database and postgresql:setup
after: deploy:finalize_update execute postgresql:create_symlink

Unicorn

Settings
  • :unicorn_user - default: user meaning ssh user
  • :unicorn_pid - default: "#{shared_path}/pids/unicorn.pid"
  • :unicorn_sock - default: "/tmp/unicorn.#{application}_#{stage}.sock"
  • :unicorn_config - default: "#{shared_path}/config/unicorn.rb"
  • :unicorn_log - default: "#{shared_path}/log/unicorn.log"
  • :unicorn_workers - default: 2
  • :unicorn_timeout - default: 30
Commands
command description
unicorn:setup Creates a unicorn config and init script
unicorn:start Starts the unicorns
unicorn:stop Stops the unicorns
unicorn:restart Restarts the unicorns
unicorn:upgrade Upgrades the unicorns
default callbacks:

after: deploy:setup execute unicorn:setup
after: 'deploy:startexecuteunicorn:start<br /> _after_: 'deploy:stop execute unicorn:stop
after: 'deploy:restartexecuteunicorn:upgrade`

Uploads

Settings
  • :upload_path - default: "#{shared_path}/uploads"
Commands
command description
uploads:setup Creates and upload folder in shared/uploads
uploads:create_symlink Symlink public/uploads to shared upload folder
default callbacks:

after: deploy:setup execute uploads:setup
after: deploy:create_symlink execute uploads:create_symlink

capistrano-recipes's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.