[Rails] Make capistrano ask for the password first
I frequently find myself doing
rake deploy with capistrano, and then wander off to do something else, while the checkout process runs its minute-long course. And then I forget what I was doing, and only 15 minutes later stumble upon that shell buffer again, only to discover that it’s still sitting there, waiting for my sudo password so it can restart the dispatchers.
Well, with this little snippet in my
deploy.rb, it now asks for my sudo password up-front, so it’ll still be cached and valid when it really needs it at the end:
task :before_deploy, :roles => :app do send(run_method, "date") end
That’s it: Force it to execute some shell command using sudo. It doesn’t matter which, so long as it doesn’t actually do anything. I chose
date. Calling run_method instead of sudo directly will ensure that if you’re not using sudo, it won’t ask for your password here, either.
Leave a comment