Archive for February, 2010

Getting 502 Bad Gateway with Passenger after cleaning gems

Thursday, February 25th, 2010

502 Bad Gateway

Recently I was updating some gems on my server. I did a gem update and a gem update –system. Everything seemed to be running smoothly. However a few minutes later I was checking my sites and I discovered that all of my Rack based sites were down and giving a 502 error.

The Background

In my short experience being my own webmaster, I’ve found that the 502 error code is the most unhelpful of error codes. It means that your app is not working. After a few times checking my error logs I noticed that the error that was bubbling up was “No such file or directory”. So I took this and searched through my apps looking for a file that might be missing

After a few hours of searching, restarting Nginx and reinstalling passenger, my apps and my gems, I took some time to think about the issue. I realized that all of my passenger apps were now suddenly failing, but my wordpress blog was still chugging along just fine. So I decided that the problem must be with Passenger.

The Culprit

After much digging around, I found that the Nginx config was still pointing to the Passenger version 2.2.9. A version I’d removed with gem clean many hours before. Once I updated this to version 2.2.10, which was the current version installed, everything started working again.

The Moral

If you update Passenger make sure that your webserver configuration is pointing to the new version.

Ruby Wisdom

Wednesday, February 17th, 2010

I got this error today testing a Rails 3 app that I’m working on..

  3) Error:
test_updates_status(QueueWorkerTest):
NoMethodError: undefined method 'save!' for "g":String
    /home/rubyyot/working/stuff.longshotlabs.com/lib/stuff/queue_worker.rb:66:in 'block in retrieve_item_info'
    /home/rubyyot/working/stuff.longshotlabs.com/lib/stuff/queue_worker.rb:64:in 'each'
    /home/rubyyot/working/stuff.longshotlabs.com/lib/stuff/queue_worker.rb:64:in 'retrieve_item_info'
    /home/rubyyot/working/stuff.longshotlabs.com/lib/stuff/queue_worker.rb:38:in 'process_unit'
    /home/rubyyot/working/stuff.longshotlabs.com/lib/stuff/queue_worker.rb:14:in 'process_queue'
    /home/rubyyot/working/stuff.longshotlabs.com/test/unit/queue_worker_test.rb:35:in 'test_updates_status'

Date.parse() is not your friend.

Sunday, February 7th, 2010

I’ve started looking at Ruby 1.9 with multiruby, and one of the first things that I found in testing is that Date.parse assumes European dates (dd/mm/yyyy format) in v1.9. The solution is to use strptime() instead so you can specify a format.

Date.strptime("12/31/2009", "%m/%d/%Y")

Moving soon

Monday, February 1st, 2010

I got frustrated with Dreamhost the other day because they downgraded the version of git available on the server to v1.4.4.4. That broke what I’d done with rubyyot.com. So I got a virtual server on Linode. It’s very nice so far. Hang on things will be in transition for a little while.

Can't find tokyocabinet native extentions

Monday, February 1st, 2010

I was trying out rufus/edo today after installing Tokyo Cabinet. and I kept getting the following error

/usr/local/lib/site_ruby/1.8/i486-linux/tokyocabinet.so: libtokyocabinet.so.9: cannot open shared object file: No such file or directory - /usr/local/lib/site_ruby/1.8/i486-linux/tokyocabinet.so (LoadError)
        from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from test.rb:1

The solution was to modify the LD_LIBRARY_PATH to include /usr/local/lib

#~/.bashrc
 
 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib