30 March 2007

A quick_dirty trick to set ENV[RAILS_ENV]

 I am using webbrick or Mongrel in development mode and Apache + fcgi in production mode on my site5 server (I'd recommand them, they are very reactive).

I have read that you're supposed to set ENV['RAILS_ENV'] to 'production' in environment.rb
As I am using capistrano de deploy my webapplication, I have tried to move that setting to dispatch.fcgi and it works! No need to get 2 versions of environment.rb (1 for developement & test and 1 for production)

Maybe there is a more elegant solution, I'd love to hear about it!

29 March 2007

Firefox 2.0.3 keeps crashing on my Ubuntu Edgy Eft

Since the lasted automatic update on the 25/03/2007, firefox has been very unstable. Every 20 minutes or so, it crashes with the following message:

"The application 'Gecko' lost its connection to the display :0.0;
most likely the X server was shut down or you killed/destroyed the application."


I am investigating the problem following

https://wiki.ubuntu.com/MozillaTeam/Bugs?action=show&redirect=DebuggingFirefox advices


The same version of firefox running on Windows XP runs absolutely fine, I am looking forward to reporting to the ubuntu community!!! So far, I have no clue, could it be my installation of ubuntu???


The sad truth was that before this update, firefox was more stable in Windows too ...

27 February 2007

Clearing Out Rails file-bases Sessions with cron

Adapted from Agile Web Development on Rails:
The session handler in Rails doesn’t do automated housekeeping. This means that once the data for a session is created, it isn’t automatically cleared out after the session expires. This can quickly spell trouble. The default file-based session handler will run into trouble long before the database-based session handler will, but both handlers will create an endless amount of data. Since Rails doesn’t clean up after itself, you’ll need to do it yourself. The easiest way is to run a script periodically, you could put the following command into a script
that will delete files that haven’t been touched in the last 1 hour every morning at 4am.

In the bash, run the command:
crontab -e

You'll enter a command line editor vi like, type "I" and copy-paste the following command:
0 4 * * * cd ~/YOUR_RAILS_APPS_HOME_FOLDER_HERE/; find tmp/sessions -name 'ruby_sess.*' -amin +60 -exec rm -rf {} \;

To save, type ESC, then wq in order to save the file and quit.

As far as I am concerned, I can't stand these command line software which don't give a clue about how to use them. I am sooooo looking forward a rebirth of some Pao Alto 70 spirit in the domain of User Interface: I want to see 3D, vocal commands, predictive User Interfaces !!! Damn the Monopoles!!!!