Stable Typo on Textdrive

[ Posted by Urban Hafner Mon, 13 Nov 2006 13:55:35 GMT ]

This Typo blog is hosted on Textdrive, which is a really nice hosting company. More in the style of the guys next door than your average company that just wants to make money.

One problem though is that I have a shared account on one of their severs and therefore have rather strict limits on the number of processes I can run and their memory consumption. This is of course understandable as otherwise it wouldn’t be possible for them to offer such accounts. The problem I had for a long time with this was that my blog consumed quite some memory and got killed quite regularly. To keep it running most of the times I created a cron job that I ran 4 times a day to kill my Rails fcgi instance and spawn a new one:

#!/bin/sh
APP=www
ROOT=/users/home/hafner/bettong.net/$APP
TMP=/users/home/hafner/var/run
# Kill the old process
date
kill -9 `cat $TMP/$APP-0.pid`
sleep 1
# Start a new one
RAILS_ENV=production /usr/local/bin/spawn-fcgi -f $ROOT/public/dispatch.fcgi \
-s $TMP/$APP-0.socket -P $TMP/$APP-0.pid

Unfortunately that didn’t always work. Sometimes the spawn-fcgi exited complaining that I couldn’t allocate enough memory. But it worked well enough to keep the site running often enough.

Some days ago while restoring my Typo database (don’t worry, Typo didn’t mess up anything, it was entirely my fault that I deleted all comments while only trying to delete the spam … Oh, well) I noticed that the session table was quite full. So I created another cron script that would remove all session entries older that 3 days:

#!/bin/sh
echo "Clear Typo session table"
/usr/local/bin/ruby /home/hafner/bettong.net/www/script/runner \
'ActiveRecord::Base.connection.delete("DELETE FROM sessions WHERE updated_at < now() - INTERVAL 72 HOUR")'

Interestingly though since then my blog has been running much more stable (i.e. the restart-rails.sh cron job always had to kill the Rails fcgi before spawning a new one which certainly hasn’t been the case before). So I’ve now reduced the number of times restart-rails.sh is called to twice a day. So maybe the whole contents of the session table is loaded into memory and that caused the process to be so big. I’ll see how the process behaves when running for half a day and if that works out I’ll gradually increase the running time of the process. I’ll report back to you when I have some more data.

Tags , , , , ,  | 1 comment | no trackbacks

Changing the order of lookups in lookupd

[ Posted by Urban Hafner Tue, 28 Nov 2006 13:45:33 GMT ]

So I was starting some web development these days and the code I was working on had the name of the website hardcoded. So I thought that the easiest way would be to add a new entry to the machines directory in Netinfo Manager. Unfortunately that didn’t work. It still resolved the IP address to the real one and not to 127.0.0.1. After a while I found out that lookupd (the program responsible for the actual DNS look up) searched the DNS server before the Netinfo Manager entries!

After searching for a long long time I found the article MacOSX lookupd and NetInfo by A.P. Lawrence. Changing the order of the search path of lookupd boiled down to the following lines:

sudo mkdir /etc/lookupd
echo LookupOrder Cache NI DNS FF DS  > hosts
sudo mv hosts /etc/lookupd
sudo kill -1 `cat /var/run/lookupd.pid`

This was done on Mac OS X 10.4.8 but according to the article from above it works on 10.2.6, too.

Tags , , , ,  | 1 comment | no trackbacks

CiteULike - A free online service to organise your academic papers

[ Posted by urban Fri, 22 Apr 2005 17:48:00 GMT ]

From the website:

CiteULike is a free service to help academics to share, store, and organise the academic papers they are reading. When you see a paper on the web that interests you, you can click one button and have it added to your personal library. CiteULike automatically extracts the citation details, so there’s no need to type them in yourself. It all works from within your web browser. There’s no need to install any special software.

It works similar to del.icio.us insofar as you are able to assign tags to each of your papers (or books, you can actually add every book from Amazon) and search for the tags.

Check it out!

Tags ,