On 11/7/06, skaar <skaar at waste.org> wrote:> * hemant (gethemant at gmail.com) [061106 22:32]:
> > I am sure..again I am missing something, but I am trying to start a
> > worker, when backgroundrb starts and it doesn''t seem to work.
> >
> > Here is my config/backgroundrb_schedules.yml file:
> >
> > feed_worker:
> > class: feed_worker
> > job_key: feed_worker_key
> > worker_method: do_work
> > trigger_args:
> > repeat_interval: 20.minutes
>
> try to use symbols and to specify a start time:
>
> feed_worker:
> :class: :feed_worker
> :job_key: :feed_worker_key
> :worker_method: :do_work
> :trigger_args:
> :start: <%= Time.now %>
> :repeat_interval: <%= 20*60*60 %>
Ok..skaar, I did a exact copy paste of your config to
backgroundrb_schedules.yml and here is my poor worker:
require ''rss/2.0''
require ''open-uri''
class FeedWorker < BackgrounDRb::Worker::RailsBase
def do_work(args)
# This method is called in it''s own new thread when you
# call new worker. args is set to :args
#google_url =
"http://news.google.com/news?ned=us&topic=b&output=rss"
# bcc serves trash to this site
#bbc_url =
"http://newsrss.bbc.co.uk/rss/newsonline_world_edition/business/rss.xml"
logger.info "Starting the Yahoo feed worker"
yahoo_url = "http://finance.yahoo.com/rss/headline?s="
symbol_list = NasdaqSymbols.find_all()
symbol_list.each do|sym|
temp_sym = sym.symbol.strip
temp_url = yahoo_url + temp_sym
get_feeds(temp_url,temp_sym)
end
end
protected
def get_feeds(url,temp_sym)
open(url) do |http|
response = http.read
result = RSS::Parser.parse(response,false)
result.items.each_with_index do |item,i|
begin
title = item.title[0..99]
link = item.link
description = item.description
pub_date = item.pubDate
#check if the feed is there in db
feed_data = YahooFeeds.find(:first,:conditions => ["title =
?",title])
next unless feed_data.nil?
if feed = YahooFeeds.create(:title => title,
:link => link,
:description => description,
:pub_date => pub_date,
:symbol => temp_sym )
logger.info("Saved to #{temp_sym}")
end
rescue Exception => e
logger.info("#{e.to_s}")
end # end of exception handling
end # end of results parsing
end # end of do |http|
end # end of get_feeds function
end
FeedWorker.register
Still...it doesn''t seem to work...the worker is not started. This I am
telling because...nothing comes to log files.
--
There was only one Road; that it was like a great river: its springs
were at every doorstep, and every path was its tributary.