Ruby deamon

We are building a web-based application with Ruby on Rails and MySQL
backend. The client now wants us to add various workflow features that
will eventually expand into SOAP web services.

These workflow features include tasks such as automatically sending
reminders for due tasks, or if a particular set of information hasn’t
been logged by a certain time to automatically send an email reminder.
In the future it is envisaged these reminders will be sent as SOAP
messages.

One person I have asked has suggested using a Java-based workflow engine
such as JBoss jBPM or Intalio Workflow. However I am thinking a
Ruby-based solution would be better.

The script would need to run continuously with a built-in scheduler or
daemon (has to support both Linux and Windows platforms).

Wondering what suggestions there are for a Ruby-based solution?

Rath — wrote:

We are building a web-based application with Ruby on Rails and MySQL
backend. The client now wants us to add various workflow features that
will eventually expand into SOAP web services.

It sounds like you don’t particularly need a full-blown BPM or workflow
engine with a built-in programming language, etc. Sounds rather like you
simply need to automate the scheduling of certain tasks and trigger
events based on information you find (or don’t find) in a database.
Correct?

Thanks Francis.

Yes, at the moment I will need something like that scheduling process.
In the future I would like to include SOAP, perhaps it can be added
later on.

Do you know how can I do scheduling?

Someone suggested me something about a deamon process called
backgroundRb
http://backgroundrb.rubyforge.org/
or
http://lunchroom.lunchboxsoftware.com/articles/2006/01/21/acts-as-state-machine
The link does not work but I found it on Google’s cached pages (google
for acts-as-state-machine)

Any suggestions are more than welcome.

Rath — wrote:

Thanks Francis.

Yes, at the moment I will need something like that scheduling process.
In the future I would like to include SOAP, perhaps it can be added
later on.

Do you know how can I do scheduling?

Someone suggested me something about a deamon process called
backgroundRb
http://backgroundrb.rubyforge.org/
or
http://lunchroom.lunchboxsoftware.com/articles/2006/01/21/acts-as-state-machine
The link does not work but I found it on Google’s cached pages (google
for acts-as-state-machine)

Any suggestions are more than welcome.

I may be missing something but it sounds like you don’t need anything
more than a cron job that will run once a minute, read the database,
make notification decisions (possibly recording those decisions in the
database) and then sending out emails, SOAP messages, events to a
queue-manager, or what-have-you.

We wrote a full-blown workorder-system in Ruby (not in RoR) that runs
against Postgres or Oracle, and it includes a module that notifies
interested users by email of specific system events such as actions
taken against particular tickets (work orders). We’re more than willing
to open-source this system (works quite well, by the way), but the
notification part of it works more as less as I just described. This
system actually contains a very sophisticated and complex system for
defining the notification rules (takes user authorization and geography
into account, etc). But that sounds like overkill for you.

Hi there,

Check out the daemon gem.
http://daemons.rubyforge.org/files/README.html

For windows there is also the win32-service gem
On 8/2/06, Rath — [email protected] wrote:

The script would need to run continuously with a built-in scheduler or
daemon (has to support both Linux and Windows platforms).

Wondering what suggestions there are for a Ruby-based solution?

Eaden

The easiest way to do the scheduling is to use the OS scheduler… cron
for
*nix or Scheduled Tasks for Windows. Rails has a featured called
‘runner’
which can invoke Rails code from the command line.

Say for example that I have a model in my app called Process

class Process
def self.send_mail

end

def self.clear_abandoned_orders

end

end

I can access these (or any other models) by doing

ruby /script/runner “Process.send_mail”
ruby /script/runner “Process.clear_abandoned_orders”

These could then be placed in the OS’s scheduler.

The nice thing about this approach is that it leverages the built-in
abilities of your OS’s scheduler thus eliminating a third-party product
or
service, and also allows you to use the same methods from within your
web
app.

We have a simple server monitor that uses this same approach.

I can access these (or any other models) by doing

ruby /script/runner “Process.send_mail”
ruby /script/runner “Process.clear_abandoned_orders”

These could then be placed in the OS’s scheduler.

We have a similar requirement for a factory automation workflow daemon.

Capabilities need to include:

  1. Support for many thousands of concurrent and oftentimes long-running
    workflow tasks. For example, threads that are monitoring materials usage
    and issue a message when a certain threshold is met. Threads that are
    monitoring Programmable Logic Controllers (PLCs) outputs and trigger an
    operator alert if a certain condition is met.

  2. A concern when using cron would be that it is not designed to handle
    thousands of tasks. According to one estimate I found it is designed to
    support up to several hundred tasks. We would be interested to hear of
    any real-world experiences using cron for 1,000+ tasks.

  3. Other issues include the ease of automatic and/or manual deletion of
    tasks from the scheduler.

  4. If scheduling is done by the OS, this would handle recovery from a
    server crash. However, how well does BackgrounDRb or rails_cron recover
    from a server crash?

Thoughts anyone?

frank

Frank Daley wrote:

I can access these (or any other models) by doing

ruby /script/runner “Process.send_mail”
ruby /script/runner “Process.clear_abandoned_orders”

These could then be placed in the OS’s scheduler.

We have a similar requirement for a factory automation workflow daemon.

Capabilities need to include:

  1. Support for many thousands of concurrent and oftentimes long-running
    workflow tasks. For example, threads that are monitoring materials usage
    and issue a message when a certain threshold is met. Threads that are
    monitoring Programmable Logic Controllers (PLCs) outputs and trigger an
    operator alert if a certain condition is met.

  2. A concern when using cron would be that it is not designed to handle
    thousands of tasks. According to one estimate I found it is designed to
    support up to several hundred tasks. We would be interested to hear of
    any real-world experiences using cron for 1,000+ tasks.

  3. Other issues include the ease of automatic and/or manual deletion of
    tasks from the scheduler.

  4. If scheduling is done by the OS, this would handle recovery from a
    server crash. However, how well does BackgrounDRb or rails_cron recover
    from a server crash?

Thoughts anyone?

frank

This is an entirely different requirement from the OP. I would be
looking at a full-blown message queueing system to solve this. I’m not
sure if you’re using the word “thread” in a metaphoric or a literal
sense, but I would avoid a thread-based implementation for a task like
this, for a reasons of reasons. I don’t think cron helps that much
either.

Does Ruby have anything like an enterprise-class MQ system? With full
failover, transactions, standard protocol support, and auth/az? Is
anyone else interested in something like that?

It would be nice to have an open source ruby based application that
would allow you to create basic workflow tasks and queueing of work
items - something with a graphical interface into it would be even
better. Something where I can drag and drop models onto a palette,
along with instructions of what to do when a particular field matches,
exceeds, etc… a certain value and then determine next steps would be
perfect. In short, I’m certain a very simple rules based workflow
system would find itself a home in a lot of applications - including
mine! Further, it would allow for a much better answer to a question
like this than cron or scheduled tasks - which, in my opinion, aren’t an
ideal solution for monitoring and triggering a large number of different
tasks.

Just my opinion!

Michael

Francis C. wrote:

Does Ruby have anything like an enterprise-class MQ system? With full
failover, transactions, standard protocol support, and auth/az? Is
anyone else interested in something like that?

The Factory Automation industry is currently based on Microsoft’s COM
and DCOM technologies. While there have been some recent moves towards
true industry standards, it is clear that Microsoft-based technologies
are going to be the key driver for protocols. Therefore, I would expect
that SOAP and associated web services protocols will be THE key
requirement, since that is what Microsoft is pushing.

Therefore our solution will need to manage thousands of tasks, many of
which will need to interoperate with MS-based systems via SOAP.

frank

On 4-Aug-06, at 9:39 PM, Francis C. wrote:

and issue a message when a certain threshold is met. Threads that are
any real-world experiences using cron for 1,000+ tasks.
Thoughts anyone?
Does Ruby have anything like an enterprise-class MQ system? With full
failover, transactions, standard protocol support, and auth/az? Is
anyone else interested in something like that?

Rinda would be more interesting with a persistant tuplespace and
distributed transactions(the leases might be enough with the
aforementioned persistence)

Has anyone checked out http://blog.labnotes.org/tag/reliable-msg ?

Jodi