I would like to tell you about few gems, which would make your deployment life a little bit easier. Well, it worked for me.
Our first hero on the scene is rvm-capistrano. This hero is special, he prefers only capistrano №2. But time is changing and capistrano №3 is walking on streets of our computers, so, if you have seen it and even use it then you may select another hero: rvm1-capistrano3.
But I will talk about oldies here. What does this gem actually do? It brings integration between Rvm and capistrano. There are some discusses in the internet what to use, some people prefer rbenv, other use Rvm. Actually, rbenv is very small and it has very small code base, but it doesn’t have power of Rvm, so your choice should depend on your situation. But let me talk about hero, he is waiting to be presented!
Installation is simple, because you already use capistrano, do you?
1 2 3 4
Now you should call the hero, to do that just place this line somewhere in the top of your capistrano’s deploy file:
This will bring to you few things. First of all, it extends
base to automatically
set :default_shell. Also it adds these tasks:
rvm:info– show rvm info
rvm:list– list rvm rubies
rvm:info_list– show info and list rubies
rvm:install_rvm– install RVM of the given choice to the server.
rvm:install_ruby– install RVM ruby to the server, create gemset if needed
rvm:create_gemset– create gemset
If you forget about correct syntax you can always run
cap -T rvm to list all tasks which gem provides. There are some additional tasks which you may include you can check them out in readme.
With this gem you may, for example, update Rvm on each deploy and make sure that ruby is installed:
1 2 3 4 5 6
Or set default ruby version and gemset:
Or even restrict Rvm on some servers!
1 2 3 4
Check out readme for more details about this hero.
If you use heroku then you receive email when deploy finishes. A like this feature and it is very cool that you can have the same functionality with capistrano. So, meet the second hero: capistrano-notifier.
The superpower of this hero is sending email with commits, which has been deployed, for example:
1 2 3 4 5 6 7 8 9 10
Looks pretty cool, huh? To install gem add it:
1 2 3
After that you should add some settings to be able to send mails. Here is example for gmail:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
After that each person, whose email has been provided in
:to section will receive the email after deploy. Of course, you may need some time to set thins up properly, but afterwards this feature may be very handy for a lot of people.
Last, but not least hero is capistrano_deploy_lock. I think you should know that nothing good will ever come out of two (and more) simultaneously deploys. This modest hero helps to fight with such evil.
Installation is simple:
1 2 3
Call the hero:
Make sure that all developers have this gem and config to protect your deploys. Now each deploy would be locked during deploy and would be unlocked afterwards. This protects each your deploy from simultaneously deploys of other people. Each person, who would try to deploy during current deploy would receive this message (or something like this):
1 2 3
This gem also helps in situations when your deploy fails, which gives you time to fix it (by default it is 15 minutes). This feature helped me few times. You can find more details in readme
That is all for today, thank you for your patience.
P.S. All these gems have been tested with Rails 4 and they work.