Skip to content

Instantly share code, notes, and snippets.

@halilim
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halilim/fefdd63c2fb30d069202 to your computer and use it in GitHub Desktop.
Save halilim/fefdd63c2fb30d069202 to your computer and use it in GitHub Desktop.
Capistrano Deployment Notes

Environment

  • Example ~/.bash_profile:
    [[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
    
    export RBENV_ROOT="${HOME}/.rbenv"
    
    if [ -d "${RBENV_ROOT}" ]; then
      export PATH="${RBENV_ROOT}/bin:${RBENV_ROOT}/plugins/ruby-build/bin:${PATH}"
      eval "$(rbenv init -)"
    fi
    
    export RAILS_ENV=production
  • Scheduled cron tasks don't recognize ~/.bashrc, so put special exports etc into ~/.bash_profile so that you can have rbenv built rubies in your cron jobs.
  • It does bash -l -c by default, so it will work with the above combination.

  • Custom command definition for running commands within the release directory (e.g., Backup):

    job_type :command_wthin_path, 'cd :path && :environment_variable=:environment :task :output'
    
    every :day, at: '04:00' do
      # noinspection RubyResolve
      command_wthin_path 'backup perform -c backup/config.rb --trigger postgres',
                         output: 'backup/log/backup.log'
    end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment