I learned a few things that you might interested in.
First,
ruby scraper.rb stole my console so I had to daemonize the script, or even find a runner library. And I found her, named Daemons, a nice lib to run ruby scripts as daemons. Check out my config:Second, I got back console (hooray) but I wanna see the messages warn or inform me about the state of the script running in the background. Fortunately, Ruby has a nice built in logger I can use for printing to STDOUT. Cool.
Last but not least, I learned a very important thing about HTTP: sometimes it takes a way long to get a document from the cloud for any reason. Timeout for the rescue, baby!
2 comments:
Question two: why do you need a web server for such long running and heavy computing task? You have the console, you have ctrl+z, bg, fg, jobs etc. - probably the problem is with me again.
Let me explain the Ruby way (hahaha) - like Debian folks do everything with "sudo apt-get" and "no make && make install pls", they want everything in Ruby :) A webserver, a proxy, a daemon, a web framework - everything.
Of course there are people who look forward the best tool for the job at hand, and I admit Ruby is not good in multithreading. We have distributed Ruby but before ruby-1.9 you just simply cheated because of no *real* multithreading.
As of Daemons lib, it is a truly lightweight and simple way to create your own background services - written in Ruby :)
Post a Comment