Mina is an interesting alternative for capistrano. It’s really tiny, easy to configure and fast as hell. Overall usage is very well documented, so to avoid repetition I’ll just describe very specific case of deploying rails apps on a shared server through use of a gateway (or whatever you may call it).
So it happens I keep my personal project on ones of those shared servers – it’s just cheaper and I don’t have to bother with upgrades, system security etc. – assuming my provider knows what he’s doing of course ;). I can normally log through ssh on my shell account and then from that machine I can ssh to yet another machine that hosts my sites.
I assume you already setup password-less login from your machine to your primary server. Now it depends how you login to your secondary (www) server. In my case I had an system alias that logged me into that server using one command, and that alias was just an ssh command pointing to some ip with use of different public key. So first I had to allow simple ssh www-server to work. And you can easily automatically provide key for some host in your ssh configuration:
After very little configuration you should be able to do: ssh primary-server and from that server ssh web-server without a password.
As I said before – mina has great documentation, so I will just copy my deployment configuration and give you some tips what could go wrong.
Be honest I had some hard time at the beginning, what may seems weird considering what I just said before :P. Ssh’ing from one server to another just didn’t work as expected and after further investigation it appeared that I got disconnected from web-server after executing first command (the rest of script were executing on shell server or not executing at all – it just hanged)
. What you have to do to fix it is wrap whole executed script in heredoc. And that’s basically it, except there is a small catch while you are deploying, because there is external script that is loaded just for deployment. It is in
mina/data/deploy.sh.erb, so don’t bother patching ssh_helper as I did ;–). Script itself loaded in
deploy_helpers.rb, so you may want just to modify and include this updated file in your deploy.rb, or you may want fork the project and made your own modifications. Whatever solution you choose it the end you should wrap it all within something like:
1 2 3
And here is my (still very fresh – so expect update in the future) deploy file configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Note that I don’t use provided bundle:install command – instead I’m linking my custom bundler configuration. I’m aware this is very specific configuration with some weird workarounds, moreover if you’re planning of using whole tasks I just recommend forking the project on github and adjusting it to your needs.