RapidApp::BgTaskInterface
package MyModule; use Moose; extends 'RapidApp::BgTaskInterface'; sub getTask { my $task= ... # load a RapidApp::BgTask::Task object, somehow. See notes on 'getTask' return $task; } 1;
This module provides the interfaces needed for the Ext.ux.RapidApp.BgTaskRenderPanel. In the future, it will also have the methods needed for the planned javascript interface that provides a line of stdin, and tabs for stdout/stderr, and a metadata inspector.
Whether or not the refresh polling should be initiated during the constructor of the javascript panel. This only affects the javascript generated by $self->renderPanel_js (and $self->content)
Parameters which should be sent to the client during creation and returned to the controller on each request. Same as Ext's "base_params", but with a better name. This only takes effect when $self->renderPanel_js is called.
Whether javascript read requests are permitted to read stream data from the job. You will likely want to override this attribute with a custom function.
Whether javascript write requests are permitted to write to streams of the job. You will likely want to override this attribute with a custom function.
Returns a RapidApp::BgTask::TaskClient object.
This method is abstract, and needs to be implemented in the derived class. Simple (but inefficient) implementation:
# open connection to task supervisor on each request my $taskPool= RapidApp::BgTask::TaskPool->new(path => '/tmp/foo'); my ($t)= $taskPool->search({ meta => { name => 'My Task' }}); die "Can't find task" unless $t;
Better implementation by caching the taskpool and pid:
# keep taskPool allocated somewhere else (in a ::Model perhaps, or in the main application) package MyApp; has taskPool => ( is => 'ro', default => sub { RapidApp::BgTask::TaskPool->new(path => '/tmp/foo', mkdirIfMissing => [ 0755, undef, undef ] ) } ); package MyModule; if (my $pid= $self->c->session->{'my_module_task_name_pid'}) { my $task= $self->c->taskPool->taskByPid($pid); return $task if $task && $task->connect(my $err); } my ($task)= $self->c->taskPool->search({ meta => { name => 'My Task' }}); die "Can't find task" unless $task; return $task;
An even better implementation would be to hold open the connection to the task supervisor, but then you need a way to close the connection if it goes unused for a while, to conserve resources.
Get the javascript to create a BgTaskRenderPanel fromo this module's configuration.
Write data to STDIN of the job.
Read from STDOUT of the job. No support yet for STDERR, so you should redirect STDERR into STDOUT within the job. (This is the only way to see them in proper sequence anyway. The Supervisor has no record of which lines of data came first between two streams. Adding such timestamps might not be a bad idea, but would only tell which stream the Supervisor read first, not which had data on it first.)
Convert terminalisms into HTML.
At the moment, this just handles "\r" processing. In the future it will also handle colors. No support is planned for cursor-moving features that cross line boundaries.
To install RapidApp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RapidApp
CPAN shell
perl -MCPAN -e shell install RapidApp
For more information on module installation, please visit the detailed CPAN module installation guide.