4
Dec
Posted by Chris Hartjes in Chris' Brain. No Comments
I had recently upgraded to a new laptop (white MacBook) and had just gotten stuff setup up the way I liked. So I continued doing development work for my latest work-related project and it was time to push the changes up to the staging server. Oh wait, I hadn’t installed Capistrano yet. So I installed that and found, oooh, we moved up to version 2.1. Cool! Progress is good.
So I go to deploy and WTF!?!??! It won’t work!??! No error messages except to say the remote command failed. I dig around on google. The amount of documentation available for Capistrano 2.0 (or 2.1 for that matter) makes CakePHP’s slowly-growing documentation look like Wikipedia. God damn it, why would you release something that breaks so many things and then don’t tell people WHY it won’t work. Maybe I’m doing something wrong, but I’ll be damned if I can figure out what it is.
So, on to the backup plan. Phing, despite it’s use of XML which I am not huge fan of in terms of it’s use as a configuration file, but at least it’s PHP and there is lots of documentation on how to use it. Now, where did I put Travis Swicegood’s e-mail address…
Article Tags >>
capistrano ||
Phing ||
PHP
31
Oct
Posted by Chris Hartjes in PHP. 2 Comments
So, I need to deploy changes to a work-related project from my laptop to a dev server. I was told that one of our other developers had a solution using shell scripts, but I couldn't figure out a problem with it and didn't want to hack away at his scripts in case I broke something he was depending on. So, I figured it was time to go back to Capistrano and simply hack my deploy script I had used for another deployment to fit this circumstance.
So, off I went hacking away at it and testing it. Then I discovered something: I need to be able to send a password for both running some commands on the remote server and for checking some stuff out of a SVN repository. So, I did some googling and here's what I came up with:
RUBY:
-
task :deploy do
-
run "sudo cp -r #{deploy_to} #{deploy_to}-old" do |ch, stream, out|
-
ch.send_data "#{sudo_password}\n" if out =~ /Password:/
-
end
-
-
run "sudo svn --quiet --force #{checkout} #{repository} #{deploy_to} do |ch, stream, out|
-
ch.send_data "#{svn_password}\n" if out =~ /.xmlteam.com's password:/
-
end
-
end
-
-
task :rollback do
-
run "sudo mv -r #{deploy_to}-old #{deploy_to}" do |ch, stream, out|
-
ch.send_data "#{sudo_password}\n" if out =~ /Password:/
-
end
-
end
All those #{...} values are simply variables I defined in the recipe file. You don't actually expect me to tell you what my passwords are for access to various machines, do you?
I remember how difficult this stuff was to do in previous versions of Capistrano, requiring all sorts of hacks to make it deploy non-Rails applications but they removed that dependency with Capistrano 2.0, thus making it possible to use Capistrano with ANY project, not just a Rails one. Although you can use a lot of built-in magic if you use Capistrano to deploy a Rails project.
Now that I know how easy it is to pass data to the remote server, I can actually envision some fairly complicated deployment scripts. Hope this helps out other people who've come here and read my other post about using Capistrano to deploy their CakePHP projects.
Article Tags >>
capistrano ||
PHP
Recent Comments