Thursday, March 12, 2009

Migrating an RoR app from Ubuntu Feisty to CentOS 5.2 Part 4: Trying not to get impaled by Vlad

This is a continuation from Part 3:
  1. I've installed mod rails
  2. I've built and migrated the database (and enabled script/console)
  3. I've built and installed RRDTools.
In this part I get Vlad the Deployer working.

Local Machine Changes
(1) In my local /config/deploy.rb I changed the :domain value to point to my new box:

set :domain, "xen-5.evri.corp"

(2) I tried to run vlad:setup. My remote install commands, run via SSH, were not being found.

Server Machine Changes

The problem with ssh seems to that my user environment is not being established with a non interactive terminal. Even after I modified my /etc/profile or files in /etc/profile.d or ~/.bashrc , even though that is how I understood non interactive terminals get their env variables. The problem was that the default sshd_config does not allow user environment variables to be set via sshd. So in /etc/ssh/sshd_config, change

# PermitUserEnvironment no

to

PermitUserEnvironment yes

I reran vlad:setup

rake vlad:setup rake full_vlad (I've modified my rakefile as follows: task :full_vlad =>['vlad:update','vlad:migrate'...all other tasks I need to do ]
As a final step, I asked OPS to map the old server name "dashboard" to map to the new server.

Are We There Yet?
No.

I run a set of ruby cron jobs on the machine (TODO: migrate these to use DaemonSpawn??), I migrate cron settings over by

crontab -l > cron
scp cron to new machine
crontab cron

Now I run rake full_vlad, and the server deploys after a full source update and database migration.

Unfortunately, my graphs are not showing any data. wtf?

I call rrdtool via IO.popen to extract my data from rrd files. On the centos box, IO.popen is not returning a readable IO object. I cannot repro with script/console from the production box (i.e. that gives me valid IO).

Some sleep and investigation reveals that the environment variables for my user are not being set when Ruby spawns a process. This, again, is unique to centos. So I hardcode the path of rrdtool in my IO.popen call, and am now receiving data.

No comments:

Post a Comment