Hi all,
I''m trying to replace an OpenWFEru/daemons-based infrastructure, with
the
goal being to be able to communicate with the workers to a) monitor current
state and to b) initiate new actions.
The short version on why these are daemons and not transient workers (that
start up and shut down when they''re done with a particular task) is
because
they''re subscribing to an external pub/sub infrastructure, and are
aggregating data or monitoring the data around the clock.
I''ve been struggling for a few days now, and I''m hoping
someone can point me
in the right direction, or else tell me that Backgroundrb isn''t the
right
tool for the job. My set of requirements that I''m having trouble with
are
pretty straightforward, so I would think maybe someone else has run into
them. Here goes ...
1) I want to have separate log files for each daemon.
I''ve managed to accomplish this by setting the MetaWorker''s
@logger to an
instance of a proper Logger. I''ve also redirected STDOUT/STDERR by
using
reopen(). Pow!
I''m worried, though -- isn''t this going to break something? I
haven''t seen
anything that''s obviously broken, but I''m only two days into
the effort, and
only ankle-deep in the code. I need enlightenment.
2) I want to know if it dies, so that I can restart it and send myself an
email.
With OpenWFEru I have a wrapper script which invokes the daemon via system()
and watches for unsuccessful exit codes. Is there an equivalent
best-practice for this in the BDRB universe?
3) I want to be able to shut down cleanly
Workers don''t seem to be given the opportunity to shut down cleanly.
I''ve
tried defining a SIGTERM handler, as well as redefining the terminate_me()
and shutdown() methods, but I can''t get this to work. Anybody have any
guidance here?
4) I want to be able to monitor current status
After the pattern of Linux daemons, I''d like to be able to run
"./script/backgroundrb status" and get my status back. I can submit a
patch
for this if anyone else is interested.
However, I noticed while writing that patch, that query_all_workers() seems
to be broken in the trunk r302 (status for all workers is always nil). So my
workaround for now is to use ask_status():
t_response = MiddleMan.query_all_workers
t_response.each {|k,v| puts "#{k}: #{MiddleMan.ask_status(:worker
=>
k)}" }
Anyhoo, that''s it. That really rambled on longer than I thought it
would.
Please let me know if I can clarify any of my questions, and thanks to
everyone for their patience with my long-windedness.
Thanks,
-mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20080103/b7e6df2c/attachment-0001.html