Archive for the ‘Uncategorized’ Category

My Upgrade to Snow Leopard Journey

After the upgrade I had a ton of issues getting my rails environment back online which I could have avoided IF I just would have uninstalled all my ports.

The problem was that I had both Ruby 1.8.6 and 1.8.7 installed as ports and that was conflicting to the new 1.8.7 that was installed from the upgrade. I could not get passenger to boot after the upgrade…

SO what I did was upgrade xcode, upgrade port then force uninstall ALL ports and install the ports that I wanted. (Reboot ūüôā ) and then I installed the passenger gem using the native 1.8.7 Ruby install.

Getting paperclip to work with passenger not running under root

After moving from Thin to passenger to save memory on one of my VM (with only 256mb every byte counts… ) I could not get paperclip to re-size images.

This was the error I got:
[paperclip] An error was received while processing: #
[paperclip] Processing medium # in the thumbnail processor.
[paperclip] An error was received while processing: #

The problem was permissions on the rails tmp directory. When I deploy using Capistrano the RAILS_ROOT/tmp directory is cleared-out so the .ruby_inline setup is re-initialized by the root user. Since I don’t run Passenger as root this throws the error above. Here is how I get around this without logging in to the server after deploy and executing a chown command:

In my RAILS_ROOT/config/environments/production.rb file I added this to the bottom:

temp = Tempfile.new(‘ruby_inline’, ‘/tmp’)
dir = temp.path
temp.delete
Dir.mkdir(dir, 0755)
ENV[‘INLINEDIR’] = dir

This replaced the old setup that I had:
ENV[‘INLINEDIR’] = File.join(RAILS_ROOT, ‘tmp’)

So now I delete the .ruby_rails directory with the wrong permissions and create a new directory with the rails user… nice!

where does the php.ini file go?

The Problem

I needed to add more memory to php but by default php installed from source (configure && make && make install) does NOT install the php.ini file. So where is waldo?

The Fix

Here is a code snip that shows what configuration file IS loaded when php is executed:

[root@mybox php-5.2.10]# php -r "phpinfo();" | grep Configuration
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => (none)
Configuration

This shows that the php.ini path is in /usr/local/lib. So I grabbed the php.ini-recommended, copied that file to /usr/local/lib/php.ini and this file has the memory_limit set to 128MB which should be enough for now….

[root@mybox php-5.2.10]# php -r "phpinfo();" | grep Configuration
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini
Configuration

Done!

Fancy Mac (OS-x) Prompt

The Problem

Boring promt

The Fix

– Open a Terminal window.

– Edit your .profile or create a file like so vi ~/.profile

Add the following to the file:

alias vi=’vim’
3
4 alias ol=’ssh root@192.168.10.206′
5 #alias cade=’ssh 74.86.232.5′
6 alias cade=’ssh 74.63.12.158′
7 alias oce=’ssh root@74.208.45.99′
8
9 # colors
10 export CLICOLOR=1
11 export TERM=xterm-color
12 export LSCOLORS=gxgxcxdxbxegedabagacad  # cyan directories
13 export PS1=’\[33[01;32m\]\u@\h\[33[00m\]:\[33[01;36m\]\w\[33[00m\]\$ ‘

# Starts the extended vi when using vi
alias vi=’vim’
# Nice listing using ll
alias ll=’ls -Alhp’

export CLICOLOR=1
export TERM=xterm-color
# Information about the colors at the bottom of the article
export LSCOLORS=gxgxcxdxbxegedabagacad  # cyan directories
export PS1=’\[33[01;32m\]\u@\h\[33[00m\]:\[33[01;36m\]\w\[33[00m\]\$ ‘

This will make sure that you prompt will have ansi colors and look something like this:
freddy@svn:~/Documents$ ll drwxr-xr-x  17 freddy  staff   578B Feb 10  2008 cadechristian.com_project/ -rw-r--r--@  1 freddy  staff   112K Mar  1  2008 server.docx drwxrwxrwx   4 freddy  staff   136B Jan 28  2008 server_backup/ -rw-r--r--@  1 freddy  staff   559K Mar  3  2008 sunJVM-on-intel-multicoreservers.pdf -rw-r--r--@  1 freddy  staff   556K Mar  1  2008 tomcat_performance_tuning_20071015.ppt freddy@svn:~/Documents$ 

LSCOLOR information

These are the available ANSI colors:

a     black
b     red
c     green
d     brown
e     blue
f     magenta
g     cyan
h     light grey
A     bold black, usually shows up as dark grey
B     bold red
C     bold green
D     bold brown, usually shows up as yellow
E     bold blue
F     bold magenta
G     bold cyan
H     bold light grey; looks like bright white
x     default foreground or background 

Note that the above are standard ANSI colors. The actual display may differ depending on the color capabilities of the terminal in use. The order of the attributes in the LSCOLORS variable is as follows:

  1. directory
  2. symbolic link
  3. socket
  4. pipe
  5. executable
  6. block special
  7. character special
  8. executable with setuid bit set
  9. executable with setgid bit set
  10. directory writable to others, with sticky bit
  11. directory writable to others, without sticky bit

They are set in pairs, foreground (f) then background (b), i.e. fbfbfbfbfbfbfbfbfbfbfb for all 11 settings. The default is exfxcxdxbxegedabagacad, i.e. blue foreground and default background for regular directories, black foreground and red background for setuid executables, etc.

check_apache.pl and perl module issue

The problem

[nagios@den2lweb002 libexec]$ ./check_apache.pl
Can’t locate LWP/UserAgent.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at ./check_apache.pl line 32.
BEGIN failed–compilation aborted at ./check_apache.pl line 32.

[nagios@myserver libexec]$ ./check_apache.pl -H localhost

Can’t locate LWP/UserAgent.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at ./check_apache.pl line 32.

BEGIN failed–compilation aborted at ./check_apache.pl line 32.

The fix

Lets find the missing LWP/UserAgent.pm module. After searching around on Google I could not find that module alone but I found the Bundle::LWP, so I started this command after a quick su to root…

[root@myserver libexec]# perl -MCPAN -e ‘install Bundle::LWP’

And after about 2 minutes the bundle was installed

Then I dropped back to the nagios user and tested the check_apache.pl command again…

[nagios@myserver libexec]$ ./check_apache.pl -H localhost

HTTPD ok: average response time 184 milliseconds

We are back in business!

Versions used

  • Linux¬†Red Hat Enterprise Linux Server release 5.3
  • Perl¬†v5.8.8 built for x86_64-linux-thread-multi
  • Ground Works 5.3 community edition

Eclipse MemoryAnalyzer Exit Code=-1

I was looking for a nice tool to read java heap dumps and found that regular JHat was not a great way to go with the 1.6GiB dump files I have. A friend pointed me to a Eclipse project Memory Analyzer (MAT) http://www.eclipse.org/mat/ which is the old SAP analyzer…

Starting it up I got the Exit Code=-1 error and found that this tool is currently not working with java 1.6.x on a mac. If you want to force the tool to use 1.5 open a terminal window and follow these instructions:
freddy@svn:~/mat/MemoryAnalyzer.app/Contents$ pwd
/Users/freddy/mat/MemoryAnalyzer.app/Contents
freddy@svn:~/mat/MemoryAnalyzer.app/Contents$ vi Info.plist
Uncomment this line:
… eworks/JavaVM.framework/Versions/1.5.0/Commands/java
This will force the use of Java 1.5!

uninitialized constant CGI::Session (NameError)

After upgrading one project to Rails 2.3.2 I got an error on startup uninitialized constant CGI::Session (NameError)

Looking into the source I found that I was loading this class CGI::Session::ActiveRecordStore::Session
After a little hunting on Google I was directed to the Rails release notes and found this section:
script/server has been switched to use Rack, which means it supports any Rack compatible server. script/server will also pick up a rackup configuration file if one exists. By default, it will look for a config.ru file, but you can override this with the -c switch.
CGI::Session::ActiveRecordStore has been replaced by ActiveRecord::SessionStore.
Done!