-1

I am trying to write a web application that interacts with a service that would run scripts at the system level. Something like a website that you can schedule a job, the service will run the job with the given inputs, write the outputs to a database, and inform the website of its status.

A few questions:

How is this typically done? Do I write to a "JOBS_QUEUED" table in my database and have the service check that? How can I pass a "% done" back to the web page? Is there a name for this type of thing?

Not sure if it matters, but I am working with Ruby on Rails right now.

5
  • 1
    This question will probably be closed for off-topic but here is a blueprint: Considering this model: APP1 calls APP2. APP1 is not going to be aware of the inner workings of APP2. So APP1 needs to make an initial entry in the DB and pass an ID to APP2. APP2 will take that ID and update it with a percentage at various points during APP2's lifespan. APP2 will tell APP1 that it has finished so APP1 will update the process to done. During this APP1/APP2 interaction you will need to poll the DB with APP3 and report the percentage to the user.
    – MonkeyZeus
    Jun 23, 2014 at 15:29
  • Adding to my initial comment you could put small descriptions of what is going on so that the 30% mark could say something like Connecting... and then switch to Requesting data and then 40% can say 850 records found and then Retrieved: 1/850 and then Retrieved 45/850 and so forth
    – MonkeyZeus
    Jun 23, 2014 at 15:33
  • Is APP3 something like sidekiq?
    – Jeff
    Jun 23, 2014 at 15:36
  • Beats me, I use PHP. Because you specified web application I assume you know how to use AJAX and interact with the HTTP protocol.
    – MonkeyZeus
    Jun 23, 2014 at 15:41
  • If you want a real time progress bar (IE not polling a database) you'll have to use web sockets to keep in sync with the server and then the server will need to update the client as it gets notified of a change, but this whole idea won't work unless the server has a way of being notified of changes rather than polling itself. Jun 23, 2014 at 23:11

1 Answer 1

1

There are many ways this could be done. One way I have seen it done:

  1. A web application adds a record to a job queue. The new job ID is saved in the user's web session, to make it easier to find the jobs of the user.

  2. Another background process periodically scans the table for new jobs that have not yet been started. When it finds such a job, it then starts processing it.

  3. The web user can see the progress of their job by refreshing a page which runs a query using the saved job ID. In this case, progress is just the name of the current status, there's no "% complete". That could been done with AJAX, but it's not.

If you have very specific questions about doing this in Rails, it might be better to ask those questions on Stackoverflow.

1
  • Thanks. I probably will ask on SO, but I needed to know some of the general information.
    – Jeff
    Jun 24, 2014 at 13:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.