Question

I've got two applications: Interface is a Rails app and Processor is for bash scripts.

I need to notify an Interface user's session if a bash process on Processor fails. I have access to the command line on Processor, so I can hit http://interface.com/process/12/error/:error_message with :error_message set on Processor.

I'm not sure how to make that work though. That route works from the browser, but I don't know how to redirect the user with the error message.

Any help would be great.

Thanks.

Was it helpful?

Solution

To answer this, I am going to make some assumptions about your setup. Please correct me if I don't have it right.

I assume that your Interface user is monitoring your site by visiting a page such as http://interface.com/process/12/monitor on the Interface server and you want the error message to pop up to let them know something went wrong.

Given that, consider having your call to http://interface.com/process/12/error/:error_message store the error in a related ProcessError table. Then, use javascript on the monitor page to poll the Interface server for "new" errors. The polling interval really depends on the situation. If you're the only user, every second would be fine, but if there are going to be lots of monitoring users at once, you would probably want to make the polling interval longer. How long depends on load and how important it is that the user is notified quickly.

A push solution would be more efficient, but is a bit harder to accomplish. If this is appealing to you, have a look at Faye, a publish-subscribe messaging system that supports Rails servers and html+javascript clients.

Hopefully this points you in the right direction!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top