PDA

View Full Version : Launch script on server & monitor. How to proceed ?



fabads
13 Jun 2010, 9:34 AM
Hello,

I need to launch a script (cgi for example) on my server. Once launched, the script monitors a system through the serial port every 5 seconds and the data are available in a json file (for example, but i can do everything).

My question is : what is the best way to launch / stop the script and display the data periodically ?

Thx a lot for your support.

Animal
13 Jun 2010, 9:29 PM
Monitor another script through Ajax every 5 seconds which returns status.

fabads
14 Jun 2010, 3:48 AM
Hello, not sure to understand.

Instead of having a request / response scheme, is it possible to push data (the server) without waiting for a request and polling for available information (the client, ie the browser).

Because today my server is a low performances NAS, I'd like to avoid to pass through a JSON file.

Animal
14 Jun 2010, 3:56 AM
Launch it through a script tag, and then have the server script send back javascript fragments periodically to keep the UI updated.

fabads
14 Jun 2010, 4:05 AM
Waouh, slowly, I'm a beginner and I'm a little bit flooded.
In my current implementation, I want to update a highchart (I use highchart adapter found on this forum). Highchart is connected to a JsonStore that's doing a request on an url (JSON file).
What are the ext components to use to do what you explain ?

Mike Robinson
14 Jun 2010, 7:07 AM
I think that what folks are saying is this:


On the server, and by some means known only to it, you'll have a thread (or a daemon or service or whatnot) that is polling that serial-port and updating some dataset with observations.
Meanwhile, the client is using some ExtJS feature, e.g. a timed task, to periodically ask the server to send the latest goodies. This is simply an AJAX request. (Or, "see below.")

Notice that you've got two computers doing causally-related things "on a regular basis," but the two timed activities actually have nothing to do with one another, implementation-wise. The server is gathering information and responding requests to dole it out to the clients. The clients, individually, are periodically requesting data updates and using the data to refresh their own displays.

It's also possible that you could implement the client-side code by using a JsonStore that is periodically "reloaded." The JsonStore issues a request that the server automatically understands to mean, "send me the latest rows," and the server responds in a JsonStore-compatible way. (So, now, the Store object is the one that "issues the AJAX request," and the client-side implementation is thereby made much simpler.)

fabads
15 Jun 2010, 4:52 AM
Hello Mike,

Thanks a lot for your very clear explanations. I'm in phase with that and my current implementation is similar to that described.
Some comments :

1. On the server, and by some means known only to it, you'll have a thread (or a daemon or service or whatnot) that is polling that serial-port and updating some dataset with observations.Yes, I have a cgi script written in perl, opening the device, retrieve data each 5 seconds & write the data in a json file

My doubts are on :
- the choice of writing into a json file instead of anwsering to a client request.
- I dont know how to develop a script polling for requests AND for the serial device at the same time. (and I don't know if it possible)
- the performances of the different solutions.

2. Meanwhile, the client is using some ExtJS feature, e.g. a timed task, to periodically ask the server to send the latest goodies. This is simply an AJAX request. (Or, "see below.")Yes, I use a Json store (with the url on the JSON file) and a Ext.TaskMgr executed every 2 seconds calling the store.load() function.
So on a file, the AJAX request does not ask for a script but simply read the file.

Best regards.