Place a request on the queue.
Syntax:
request may be anything, but is usually a single line of text.
returns the id of the request, in the form of a unique.timestamp.
Place a request on the queue. The request is either the contents of a file, or stdin.
Syntax:
or
where filename is the name of a file.
stream is a process that generates the contents of the request.
Returns the id of the request, in the form of a unique.timestamp.
Note: It is a contents of the file that is placed on the queue, not the filename. Once the request has been queued, the file is no longer required, and the user is free to remove it, or modify it, without having an effect on the queued request.
You must not use more than one of doNext and/or flushQueue at any one time. Also, do not use either of them if a daemon is running (documented below).
Process the next (n) request(s) from the queue
syntax:
where n is the number of requests to process. n defaults to 1.
Process all requests pending on the queue.
syntax:
Will continue until no requests are pending.
Pause flushQueue. After the current request is completed, flushQueue will pause (that is, go to sleep). Use unpause to resume processing.
Syntax:
What the QueueReader finally does with the request.
Syntax:
The filename is relative to the base directory for the QueueReader.
The default action, implemented by the framework, is to simply stream the contents of the request to stdout.
This is one method that is likely to be over-ridden for a clone of QueueReader. (the other is daemon)
Process a request from the queue
Syntax:
The actual sequence is as follows:
1. The request is moved from the queue/ subdirectory to the done/ subdirectory. The filename is changed to indicate that processing has commenced.
2. The performRequest method is run.
3. The file on the done/ subdirectory is touched to bring it up to date (using the Unix touch utility). This is important for archiving, since it provides an indication of how long ago the request was run rather than how long ago the request was queued.
4. The filename on the done/ subdirectory is modified to show that the request was completed, and to indicate the time that the request was completed.
Stop flushQueue after it has finished processing its current request
Syntax:
Un-pause flushQueue. Will resume flushQueue if paused.
Syntax:
The daemon provides a 'set-and-forget' method for processing methods as they arrive. Once started, the daemon can be stopped, paused and unpaused using the same methods as you would use for flushQueue. (See documentation for stop, pause and unpause, above.)
You can pipe the output (stdout) from the daemon to another process by setting the pipeDaemonTo key and using the start method. Once set, the key will be used whenever the start method is used.
Start (in the foreground) a process which will continue to flush the queue on regular basis.
Will not run if a daemon is already running (or appears to be running).
Syntax:
Used by the daemon to sleep when there are no requests on the queue.
Syntax:
The key daemon.sleep.time stores the time (in seconds) that the deamon should sleep before checking the queue again.
Shoot the daemon dead. Be warned, however, there may still be a run-away process left over from performRequest.
syntax:
Start the QueueReader daemon as a background process.
Syntax:
Returns the pid of the daemon process.
You can pipe stdout from the daemon to another process by using the key pipeDaemonTo. Set this key to a shell command. The command will be run, and the daemon output piped to it.
Determine the status of the daemon.
Syntax:
Possible responses are:
Wake the daemon if it is sleeping.
Syntax:
These methods are useful for someone administering the daemon.
Archive the done/ queue, by moving any requests older than one day (including one day) to another directory, then tarring that directory.
Syntax:
directory is the name of the directory to be used. It is optionally created. It may be given as an absolute path, or relative to the QueueReader base directory.
If not given, it defaults to done.YYMMDD where YYMMDD is today's date .
Show contents of all requests pending
Syntax:
Show the contents of the last (n) request(s) to have been processed
syntax:
where n is the number of requests to show. n defaults to 1.
Show the contents of the next (n) request(s) from the queue
syntax:
where n is the number of requests to show. n defaults to 1.
Clear all the lockfiles, so we can restart the daemon. (Usually required after a power failure, or if the daemon dies unexpectedly.) The lockfiles are the keys created by the method manageProcess.
Syntax:
Return the number of requests currently on the queue.
Syntax:
Show the names of last (n) request(s) on the done queue.
Syntax:
The output from this method will reveal when each request was originally queued, whether it finished, and the time that it completed.
Requests that did not finish (or are currently being processed) end with .started. Requests that completed have .done. in their name.
These methods would not normally be used. They are used internally by the QueueReader.
Kill a process that is being "managed" using the manageProcess method.
syntax:
pidKey and psKey are the names of the keys that were used for the manageProcess method.
Manage a running process so we can kill it later if neccessary.
syntax:
pid is the pid of the running process.
pidKey is the key to store the pid in.
psKey is the key to store the psQuery information in.
Use ps to query a specific pid. (Used to ensures that start, status, kill and wake are robust and consistent.)
syntax:
If the keyword verbose is used, then the first line of the ps command is included. This line would normally be ignored by scripts that want just the information, so it is removed by default.
(20100523 19:09:05) This page was produced using rsml. Source file was QueueReaderAPI-0.9.0