Passenger Phusion/mod_rails System Tools

Posted by Sheldon Finlay on February 08, 2009

Passenger has really become the gold standard in easy deployment of Ruby on Rails apps. It’s amazing simple to configure and quite efficient. In addition to the installation tool, there are a couple small analysis/maintenance tools that are included for giving you some insight into how Passenger is running on your system. You don’t hear much talk about them and I quickly overlooked them at first.

passenger-memory-stats

This tool allows you to see a display of the real-time memory usage for Passenger and Apache.

passenger-status

This tool shows you what your current passenger stats are and what apps are currently running.

You can read more about both of these in the Passenger documention.

FLV Video Streaming Using Apache

Posted by Sheldon Finlay on February 08, 2009

I do a fair amount of work pseudo-streaming video using the flv_streaming module in Lighttpd. However, it’s a bit of a pain to use Lighttpd for Streaming and apache for content serving. You either have to run the two on separate servers or use a non-standard port for Lighttpd. But that seems to be changing. I have come across a couple pseudo-streaming modules for Apache. One if for streaming FLV and the other is for streaming H264. Here’s some info on using both:

mod_flvx: http://flowplayer.org/forum/5/14679

mod_h264: http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming-Apache-Version2

I have compiled the mod_flvx into Apache, but I have yet to try it out in production. I am excited about the h.264 streaming. My biggest complaint with using FLV files converted with ffmpeg is the low quality compared to vp6 encoded FLV files. ffmpeg doesn’t support vp6 given that it’s a commercial codec. But  h.264 is comparable in quality to vp6, making it an attractive alternative.

idroppedie6.com

Posted by Sheldon Finlay on February 07, 2009

It’s about time. I have been saying for a long time that we need to drop support for IE6. By continously bending over backwards to support it, we are not giving users an incentive to upgrade. The number of hours that are spend writing tweaks and debugging IE6 issues is no doubt outstanding. Probably more than time waste on IE6 debugging than the stupid “25 random things about me” meme. So here’s a site where you can add your support for dropping IE6 by adding your site to an ever growing list of IE6 deserters. It’s interesting to see some of the sites on the list so far. There are a few high-profile sites, namely Google’s gmail service.

http://idroppedie6.com/

Scaling Rails Screencasts

Posted by Sheldon Finlay on February 06, 2009

It doesn’t matter if your web site gets 10 hits a day or 10 million hits a day. It’s a good coder who plans for future growth and anticipates how a site will scale as traffic and load increases. Gregg Pollock of Rails Envy has an excellent (free!) 5 part series up at RailsLab. Definitely worth checking out. Gregg also has a (not free) Scaling Ruby screencast on the EnvyCasts web site. I haven’t watch it, but I have watched the Advanced ActiveRecord screencast and it was both informative and entertaining. Gregg and Jason make this stuff fun! So check them out.

Flushing DNS Cache

Posted by Sheldon Finlay on February 04, 2009

If you work with web sites, DNS, etc. and have to make regular DNS changes, it can often take a while for DNS changes to propagate. So you can either wait the 12 – 24 that it takes for your computer to refresh, or you can try and force a refresh by clearing your local DNS cache. It doesn’t always work, mind you.

If you are using Mac OS X, you can try:

dscacheutil -flushcache

Or if you use Windows you can try:

winipcfg /flushdns

You may need to restart your browser or which ever application you are trying to access the site with.

Errors While Installing MySQL Gem 1

Posted by Sheldon Finlay on February 04, 2009

I was installing the MySQL ruby gem this evening and ran into some errors. After some hunting around I found the solution:

gem install mysql -- --with-mysql-config=/usr/lib/mysql/mysql_config

Here’s the errors I was getting hit with. Hope this helps others who might encounter a similar problem.

Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
        ERROR: Failed to build gem native extension.

/opt/ruby-enterprise-1.8.6-20090201/bin/ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/opt/ruby-enterprise-1.8.6-20090201/bin/ruby
        --with-mysql-config
        --without-mysql-config
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-mlib
        --without-mlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-zlib
        --without-zlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-socketlib
        --without-socketlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-nsllib
        --without-nsllib
        --with-mysqlclientlib
        --without-mysqlclientlib

Gem files will remain installed in /opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

Testing a New Kernel in CentOS/Linux

Posted by Sheldon Finlay on February 03, 2009

So you just installed a new kernel and updated your grub.conf file. But you’re a little nervous about rebooting the server in case the new kernel doesn’t work out. Here’s a simple way to grub to reboot your new kernel just once. That way, if it fails, the machine can just be power-cycled and will reboot into the known to work kernel.

echo "savedefault --default=0 --once" | grub --batch

Change default=0 to which ever kernel you wish to boot once. Once you are done reboot:

shutdown -r now

Now remember, this will only boot that new kernel once. Subsequent reboots will end up booting the old default. So if everything is working like it should make sure to edit the grub.conf file and set the new kernel to be the default.

Hack-free PNG Transparency 1

Posted by Sheldon Finlay on February 03, 2009

If you’ve been around web design for any length of time you know about PNG transparency issues with Internet Explorer 6. PNG looks great in nearly every browser except IE6, and with plenty of folks still using IE6 despite its limitations, it’s a good idea to support these users as best as possible. Usually this means using Javascript hacks to exploit some proprietary features of IE6 to enable PNG transparency. But here is a an interesting screencast from Brenelz’s Web Solutions which looks pretty interesting. It’s basically a way of creating a PNG32 in Photoshop, then re-opening it in Fireworks and saving it as a PNG8 with alpha-transparency. The results are pretty impressive and the image file size is dramatically lower.

Edited: I tried this today using a PNG-32 which was previously saved in PhotoShop. The file was 16kb. The PNG-8 alpha transparency file was 4kb. 25% of the original size! In Firefox the image seemed just as good. It wasn’t as smooth as the PNG-32 given that PNG-8 has only a fraction of the color palette. The file in IE6 looked different, but was perfectly acceptable. It beat the usual method of Javascript hacks and conditional statements.