Daniel's Stuff

Month: April 2006

I’ve been doing quite a bit of development recently using Ruby on Rails under Mac OS X. Unfortunately it can be a little tricky to get rails apps deployed nicely under Apache. The machine I’m using is an aging G4 with very little RAM so running rails apps in CGI mode is very slow! Initially I tried FastCGI, but I found it to be unreliable 🙁 After a bit of looking about on the net I came across SCGI ( http://www.mems-exchange.org/software/scgi/ ) and some code to use it to run rails. apps ( http://www.zedshaw.com/projects/scgi_rails/). Installing these pieces is pretty straight forward

Alias /app2 “/Library/WebServer/RailsApps/app2/public” SCGIMount /app2 127.0.0.1:9998 <Directory “/Library/WebServer/RailsApps/app2/public”> Options +FollowSymLinks Order allow,deny Allow from all </Directory>Now we start each of the SCGI server processes by running the scgi_ctrl start command in each rails app root folder, bounce apache using sudo apachectrl graceful and the rails apps should be up and running from http://localhost/app1/ and http://localhost/app2/

That is only half of the story however. We need to have the SCGI server processes start when the machine boots. The way to do this under Mac OS X is to create a startup item. A startup item consists of a couple of files in a folder under /Library/StartupItems. One is a .plist file and the other is a shell script.

Create a folder called SCGI under /Library/StartupItems and then create the file StartupParameters.plist with the following content

Well, for one you can only do it one handed! Also you have to be ready for sudden lunges towards the keyboard. Bang bang bang go the keys. Oops a wrong click or an inopportune Enter and say goodbye to all that work. Still it is nice for the little one to see what Daddy does all day, even if I have to spend most of the time stopping her from eating any CDs and other things I’ve foolishly left just within reach 😉

I have to say that Cocoa bindings are one of the coolest things to some to Cocoa in a long time. It takes a bit of getting used to however, and the documentation isn’t the greatest. One of the things that had me stumped for a bit was how to have a button‘s enabled flag depend on more than one edit field having a value. There was only one Enabled binding. It seems that Interface Build adds more Enabled bindings as you create them. So you add an Enabled binding, and all of a sudden in the bindings tab appears Enabled2. Add another one and what do you know Enabled3 magically comes into existence 🙂I spent a little while looking to see if there was some way of doing something like Enabled = IsNotNull(field1) and IsNotNull(field2) and IsNotNull(field3), when all I had to do was just add them in.

It’s nice when the tools are smart like this, although it would also be nice if there was some documentation that said something like this would happen. I guess I should have know it would do that since it makes sense for it to do so. One of the nice things about Apple software is that it tends to just work (most of the time).