ARCHIVE: July, 2007

My last Ruby on Rails project, I implemented a full text search using acts_as_ferret (AAF). For the production environment, I used AAF DrbServer for centralised access to the index files, or you probably will scratch your head, bumping into an error message similar to this, due to concurrent manipulation of Ferret index files:

File Not Found Error occured:
tried to open "/[app_name]/[model]\_8e_0.del" but it doesn't exist: <No such file or directory>

It is easy to start/stop AAF DrbServer on Unix environment using a simple shell script as shown in the help page. Creating similar script for windows should not be too difficult, but running it in a command console, is usually a no-no for the system administrator. So the workaround is you have to create a Win32 service for AAF DrbServer.

I scoured the web hoping that someone had done the dirty job, but not my lucky day, the closest I found was an article by Sausheong on how to create a Win32 service on Rails. Picking up from there, I created some scripts that allows you to install/remove Ferret DrbServer as Win32 service through simple commands.

Let’s get started:

  1. Make sure you have installed acts_as_ferret.
  2. Install win32-service gem.
    gem install win32-service
  3. Download ferret_win32_service.zip and extract ferret_service and ferret_daemon to [app_name]/script directory.

    ferret_service script is to install/remove/start/stop your win32 service, while ferret_daemon script is to be callled by Win32 service to start/stop the DrbServer.

  4. To install AAF DrbServer as Win32 service:

    Usage: ruby script/ferret_service install [options]
        -n, --name=NAME          Service name
        -d, --display=NAME       Service display name
        -l, --log FILE           Service log file
        -e, --environment ENV    Rails environment
        -t, --trace              Display stack trace when exception thrown
        -h, --help               Show this help message
    

    Example:

    ruby script/ferret_service install -n [service_name] -e production 
  5. To remove an installed service:
    ruby script/ferret_service remove -n [service_name]
  6. To start/stop a service:
    ruby script/ferret_service start|stop -n [service_name]
    
    // or you can also run:
    net start|stop [service_name]
    

By default, ferret_daemon will create [app]/log/ferret_service_[environment].log file, unless it is overwritten when installing the service using the -l or --log option. The log file will show the trace of the service status, if it is has been started, stopped or currently listening.

ferret_daemon deamon is to be called by win-32 service, but if you need to run in on command console, use can use the -c or --console option:

ruby script/ferret_daemon -c -e [environment]

If you need to create any DrbServer as windows service, you can always take a quick look at ferret_service and ferret_daemon scripts for reference. So fear not for Win32 service.

UPDATE (Nov 27, 2007)

The scripst are now part of acts_as_ferret 0.4.3. Thanks Jens.

UPDATE (Jan 31, 2008):

You may face a problem that the service can’t be started properly after a server reboot, with “..did not respond in a timely fashion…” message in the event log. I faced the same issue as well, banging my head against the wall a couple of times. And this was what I did.

By default, the Win32 service will timeout if it doesn’t complete the start process within 30 seconds; starting rails acts_as_ferret service on windows can be quite slow, especially after server reboot, when there are so many services to be started at the same time.

So I increase the timeout to 120 seconds, just to be sure, as previous attempt to set it at 60 seconds still failed occasionally. Follow to link below on how to do that:
http://support.microsoft.com/kb/839803

The other step that I did as another preventive measure, is to configure the service to restart on failure for the first, second and subsequent failures, and configured the restart service period to be 7 minutes between each failure, to give some ample time for the server to off load the heavy CPU usage after reboot. You can do that by double click on the service name from control panel, under the Recovery tab.

And lastly, good luck. :)

I have long yearned for BookJetty to support the rating and review features, and finally last night, I managed to roll it out, and here are some highlights of BookJetty new features:

AJAX-based 5-star rating

Rate n ReviewI was considering between digg-style rating, 4-star rating and 5-star rating. But after weighing the pros and cons; for book reviews, I think the best is still the 5-star rating.

AJAX star rating system was used to speed up the rating process, and to allow users to rate with minimum effort. Mouse over to show the selected star, and click to rate. And I’m quite happy with the result, I rated 71 books in my shelves in no time.

Book Review

To review a book , you need to first add a book to your bookshelf, the book review form will appear below the book description. Latest reviews from everyone will be shown in the homepage.

Book Review

Comment on Review

A review is like a blog post, other users will be able to comment on it If someone comments on your review, depending on your email notification settings, you can be notified through email.

Bookshelves Side Panel

User profile page has also gotten a face lift, other than some reorganisation of the account maintenance menus, we can now view a user’s tags cloud, with a summary of wanted, reading and read books.

Email Notification

An additional section under you account maintenance, to configure your email notification preferences.

Recent Shouts Layout Re-design

Recent shouts layout was quite cluttered previously, they are now organised and grouped by each category, with each category showing a maximum of 4 recent shouts. It is definitely much easier to view and trace now.

Recent Shouts

What’s Next for BookJetty?

I will be looking into ways to integrate with other libraries around the world using Z39.50 protocols, which should allow retrieval of library call no, but without the holding information.

If you are a library representative, and would love to explore a closer integration with BookJetty similar with what I did for Singapore National Library Board, do drop me an email.

Other than that, some users have suggested me to look into building BookJetty-Facebook application. I’ll start reading Facebook Platform when I am freed up. And other features like the importing feature, add friends and groups, create discussion threads, and others will also be coming.

Hope you will love this batch of new features, so start rating and reviewing your books! Your feedbacks and comments will be much appreciated. :)

Two days ago, I was tagged by Design Sojourn with a meme, because he would like to dig out some the dark secrets I have in my life.

And these are the eight things you probably don’t know about me:

  1. When I was in high school, I lost so much weight out of a sudden, not knowing why, I thought something serious was happening with me, and for the first time in my life, I thought about death. Later, I found out I was at the early the stage of Tuberculosis infection. I’m forever grateful now, and considering myself living on my second-life.
  2. If blog has been around in 1991, I should have started blogging when I was 14, I penned my life summaries on a small diary. Now that I read back, I had a good laugh, we sounded so silly when we were young.
  3. For the first 17 years of life, I was never worried about what I want to be, for the next 11 years I was still searching; and only for the last two years, I found my true-self. The world is a vast forest, it’s easy to lost our way.
  4. I am still afraid of big worm; when I was a kid, while digging worms for fishing, my friend threw a pretty big fat worm that sticked on my bare back; that made me jumping up and down for a while. He’s going to pay for that one day, I plan to throw jelly fish on his bare back.
  5. My favourite cartoon character is Doraemon.
  6. I ocassionally sleep with my mouth open, I guess it’s the gene that I inherited from my dad. Bad, bad gene!
  7. When I was much younger, I was so confused about religion, with a few friends, I went for a church service, after praying and chanting in a temple. We did that for about a year or two. Poor lost kids, after all, there is only one God right? Shouldn’t all ways lead to the same God? I told you it’s confusing.
  8. I once applied for Master of Technology in National University of Singapore (NUS), but was rejected, and was a tad sad back then. Now that I look back, I’m glad I was rejected, because I applied out of peer pressure. And up till now, I still believe that out of every bad things that happen to us, there are always good things to look upon.

To keep this meme alive, I am tagging Cobalt Paladin, because he is an interesting character with his secret identity.

Goodbye National Stadium

SUN, 1 JUL 2007

Singapore National Stadium

I was there to visit the stadium’s gym, I heard it was cheap and good, $2.50 per entry. I had given up signing for gym membership, as I always ended up donating my membership fees after the third month.

I had heard a lot about the stadium, read it on paper, seen it on TV, and I never missed Singapore National Parade each year, live on TV. Yet, it felt different when you are actually standing there, in the stadium.

I was at the main gate, instead going into the gym, I decided to walk towards the running tracks, attracted mainly by the lush green fields, whose grass never seem to ever grow an inch longer. I felt like running to the middle of the field and start rolling like a lazy cat after a good meal, but I thought it might not be a good idea.

I looked at the running tracks, warmed by a late afternoon sun, the stadium was pretty much empty, a few joggers were running slowly on the track, they probably were running fast, but the tracks were so long, they appeared to be slow.

I looked up at the empty seats, gazing slowly from one end towards the other end, I felt so insignificant, I was so small, the stadium was so spacious, I felt like an ant in a big bowl.

I looked at the walls, the beams, the seats – the stadium must have been quite old, I guessed – they appeared to be washed out and parched by years of rains and direct sunlight.

I found out today, it was built in 1973. At 34 years of age, its structures still appeared strong as if saying give me another one-hundred years, and I can still host another hundred national parades.

Sadly yesterday, he bid goodbye to all of us, giving way to the new stadium.

Photo: About two months ago, photographer.sg organised a photo trip to Singapore National Stadium, out of so many shots I took, I think I finally managed to capture the soul of the stadium through this shot, strangely, he looks like the image I have of him when I first met him four years ago.

In memory of Singapore National Stadium.