mkdir /tmp/capistrano-3.2.1 cd /tmp/capistrano-3.2.1 git clone git@qacollab01.exphosted.com:/home/expbbbu/softrepo/git/capistrano.git cd capistrano gem build capistrano.gemspec gem install capistrano-3.2.1.gem gem install capistrano-bundler -v 1.1.2 gem install capistrano-rails -v 1.1.1 gem install capistrano-rvm -v 0.1.1 gem install bundler -v 1.11.2
Verify:
gem list
Output:
capistrano (3.2.1) capistrano-bundler (1.1.2) capistrano-rails (1.1.1) capistrano-rvm (0.1.1) bundler (1.11.2)
1. Create Cap directory.
mkdir ~/tincan
2. Download scripts.
cd ~/tincan wget --user=expbbbu --password=<RETRACTED> ftp://qacollab01.exphosted.com/softrepo/tincan/deploy/tincandevconfig.tar.gz | tar xz
3. Create deploy_to directory (Optional).
sudo mkdir /deploy/tincan sudo chown expdev01.expdev01 /deploy/tincan
Deploys are idempotent. Whether this is a first deploy on a fresh server or an Nth deploy, the steps remain same.
1. Login as user expdev01. It is critical that you login as expdev01 (vs. using su etc)
Example:
ssh expdev01@devlrs01.learnexa.com
2. Change to the directory containing deploy script.
Example:
cd ~/tincan
3. Execute runcap.sh
./runcap.sh
OR
cap production deploy
4. Execute release specific tasks, if any. 5. If QA / Prod release, update the dates on the Wiki. 6. Notify dev@exp
After deployment - test:
Call the runcap.sh from the cap directory
cd ~/crossbow (If the directory does not exist then you are not logged in as the correct user. DO NOT su - expprodl) ./runcap.sh
Values to review/edit in runcap.sh:
CAPDIR (current capify dir, where runcap.sh and config/* reside) MAILRECIP (recipient list for cap output)
Questions to be answered for runcap.sh
Select Target environment (select any one number): This is where the code needs to be pushed
Select Cap Task (select any one number): Capistrano task to be ran from the displayed list, you'll most likely select just the deploy option.
Enter BRANCH value (will be prompted if Cap Task is deploy): This is the branch value where the final tested code has been checked out and branched by QA/Release Team. If left empty, capistrano will point to the "trunk" for repository. Ready to run task (y or Y): Final confirmation to run the cap script, enter y or Y
Enter SVN UserName: (if Cap Task is deploy, ideally would want to have a read-only user for repos) Enter SVN Password: (if Cap Task is deploy)
Values to review/edit:
user and servers(ssh user to app/db servers) SSH Options
Values to review/edit in config/deploy.rb
deploy_to =⇒ sets the directory where application will be deployed.
repo_url =⇒ Repository URL
linked_files =⇒ List of files which will be symlinked from #{deploy_to}/shared.
linked_dirs =⇒ List of directorieslog_level =⇒ :info, :debug, :warn.
which will be symlinked from #{deploy_to}/shared.
log_level =⇒ :info, :debug, :warn.
Cap Tasks (custom/edited)
verify_tag (to verify BRANCH, sets the repository value to trunk or branch) \\ solr (stop/start solr on App servers, before and after deploy) \\ deploy:restart (restart in sequence with delay, touch restart.txt, added curl call to Application URL, curl call to server and inspect output for string.)
rvm 1.25.27 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/] ruby-2.1.1 ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux] Please enter svn_username (Enter SVN Username): Please enter svn_password (Enter SVN Password): INFO[7b310a5f] Running /usr/bin/env mkdir -pv /deploy/tincan/shared /deploy/tincan/releases on localhost INFO[7b310a5f] Finished in 0.451 seconds with exit status 0 (successful). INFO[fc6abdce] Running /usr/bin/env mkdir -pv /deploy/tincan/shared/config/environments /deploy/tincan/shared/log /deploy/tincan/shared/public/system on localhost INFO[fc6abdce] Finished in 0.441 seconds with exit status 0 (successful). INFO[1fe48cf4] Running /usr/bin/env mkdir -pv /deploy/tincan/shared/config /deploy/tincan/shared/config on localhost INFO[1fe48cf4] Finished in 0.438 seconds with exit status 0 (successful). INFO[7392e439] Running /usr/bin/env sudo /etc/init.d/tomcat7 stop on localhost INFO[7392e439] Finished in 1.298 seconds with exit status 0 (successful). INFOThe repository mirror is at /deploy/tincan/repo INFO[3511561c] Running /usr/bin/env svn update --no-auth-cache --username <REDACTED> --password <REDACTED> on localhost INFO[3511561c] Finished in 2.807 seconds with exit status 0 (successful). INFO[9d69fb4b] Running /usr/bin/env svn export . /deploy/tincan/releases/20140609131037 on localhost INFO[9d69fb4b] Finished in 0.657 seconds with exit status 0 (successful). INFO[d853350f] Running /usr/bin/env echo "r61" >> REVISION on localhost INFO[d853350f] Finished in 0.493 seconds with exit status 0 (successful). INFO[32701db3] Running /usr/bin/env mkdir -pv /deploy/tincan/releases/20140609131037/config /deploy/tincan/releases/20140609131037/config on localhost INFO[32701db3] Finished in 0.439 seconds with exit status 0 (successful). INFO[ad9d5bec] Running /usr/bin/env rm /deploy/tincan/releases/20140609131037/config/database.yml on localhost INFO[ad9d5bec] Finished in 0.460 seconds with exit status 0 (successful). INFO[500ef8c3] Running /usr/bin/env ln -s /deploy/tincan/shared/config/database.yml /deploy/tincan/releases/20140609131037/config/database.yml on localhost INFO[500ef8c3] Finished in 0.440 seconds with exit status 0 (successful). INFO[2089a935] Running /usr/bin/env rm /deploy/tincan/releases/20140609131037/config/sunspot.yml on localhost INFO[2089a935] Finished in 0.458 seconds with exit status 0 (successful). INFO[baf8045f] Running /usr/bin/env ln -s /deploy/tincan/shared/config/sunspot.yml /deploy/tincan/releases/20140609131037/config/sunspot.yml on localhost INFO[baf8045f] Finished in 0.447 seconds with exit status 0 (successful). INFO[2140f9ab] Running /usr/bin/env mkdir -pv /deploy/tincan/releases/20140609131037/config /deploy/tincan/releases/20140609131037 /deploy/tincan/releases/20140609131037/public on localhost INFO[2140f9ab] Finished in 0.439 seconds with exit status 0 (successful). INFO[317d4ce4] Running /usr/bin/env rm -rf /deploy/tincan/releases/20140609131037/config/environments on localhost INFO[317d4ce4] Finished in 0.446 seconds with exit status 0 (successful). INFO[77d1068d] Running /usr/bin/env ln -s /deploy/tincan/shared/config/environments /deploy/tincan/releases/20140609131037/config/environments on localhost INFO[77d1068d] Finished in 0.434 seconds with exit status 0 (successful). INFO[c846cd38] Running /usr/bin/env rm -rf /deploy/tincan/releases/20140609131037/log on localhost INFO[c846cd38] Finished in 0.445 seconds with exit status 0 (successful). INFO[eaa0faae] Running /usr/bin/env ln -s /deploy/tincan/shared/log /deploy/tincan/releases/20140609131037/log on localhost INFO[eaa0faae] Finished in 0.436 seconds with exit status 0 (successful). INFO[40ab7aab] Running /usr/bin/env ln -s /deploy/tincan/shared/public/system /deploy/tincan/releases/20140609131037/public/system on localhost INFO[40ab7aab] Finished in 0.431 seconds with exit status 0 (successful). INFO[5767ab49] Running /usr/bin/env sudo /etc/init.d/tomcat7 start on localhost INFO[5767ab49] Finished in 0.550 seconds with exit status 0 (successful). INFORunning Reindex INFO[11561fe1] Running /usr/bin/env cd /deploy/tincan/current && bundle exec rake sunspot:solr:reindex on localhost INFO[11561fe1] Finished in 13.316 seconds with exit status 0 (successful). INFO[edf340a5] Running ~/.rvm/bin/rvm default do bundle install --binstubs /deploy/tincan/shared/bin --path /deploy/tincan/shared/bundle --without development test --deployment --quiet on localhost INFO[edf340a5] Finished in 3.116 seconds with exit status 0 (successful). INFO[a864b0ac] Running /usr/bin/env echo 'backup db' on localhost INFO[a864b0ac] Finished in 0.447 seconds with exit status 0 (successful). INFO[26d16737] Running /usr/bin/env ~/bin/runbackup.sh on localhost INFO[26d16737] Finished in 0.525 seconds with exit status 0 (successful). INFO[499f51c4] Running ~/.rvm/bin/rvm default do bundle exec rake db:migrate on localhost INFO[499f51c4] Finished in 5.597 seconds with exit status 0 (successful). INFO[36b8eb0c] Running /usr/bin/env cd /deploy/tincan/releases/20140609131037 && rvm default do sass --update public/stylesheets/sass:public/stylesheets/ on localhost INFO[36b8eb0c] Finished in 3.592 seconds with exit status 0 (successful). INFO[7dfe8314] Running /usr/bin/env cd /deploy/tincan/releases/20140609131037 && rvm default do rake asset:packager:build_all on localhost INFO[7dfe8314] Finished in 10.585 seconds with exit status 0 (successful). INFO[9ce068b2] Running /usr/bin/env rm -rf /deploy/tincan/current on localhost INFO[9ce068b2] Finished in 0.442 seconds with exit status 0 (successful). INFO[03b2b0fc] Running /usr/bin/env ln -s /deploy/tincan/releases/20140609131037 /deploy/tincan/current on localhost INFO[03b2b0fc] Finished in 0.440 seconds with exit status 0 (successful). INFO[429e1347] Running /usr/bin/env touch /deploy/tincan/releases/20140609131037/tmp/restart.txt on localhost INFO[429e1347] Finished in 0.444 seconds with exit status 0 (successful). INFOKeeping 5 of 6 deployed releases on localhost INFO[34254ec8] Running /usr/bin/env rm -rf /deploy/tincan/releases/20140608063652 on localhost INFO[34254ec8] Finished in 0.479 seconds with exit status 0 (successful). INFO[556e8f23] Running /usr/bin/env echo "Branch trunk (at r61) deployed as release 20140609131037 by expdev01" >> /deploy/tincan/revisions.log on localhost INFO[556e8f23] Finished in 0.430 seconds with exit status 0 (successful).
TBD