App-EvalServer
view release on metacpan or search on metacpan
OUTPUT
When your request has been processed, you will receive a JSON hash back.
If no errors occurred before the code was evaluated, the hash will
contain the following keys:
* 'result', containing the result of the evaluation.
* 'stdout', a string containing everything that was printed to the
evaluating process' stdout handle.
* 'stderr', a string containing everything that was printed to the
evaluating process' stderr handle.
* 'output' a string containing the merged output (stdout & stderr)
from the evaluating process.
* 'memory', the memory use of the evaluating process (as reported by
"(getrusage())[2]").
* 'real_time', the real time taken by the evaluating process.
* 'user_time', the user time taken by the evaluating process.
* 'sys_time', the sys time taken by the evaluating process.
lib/App/EvalServer.pm view on Meta::CPAN
sig_die
fatal_signal
server_failure
new_client
client_read
client_write
client_error
spawn_eval
eval_stdin
eval_stdout
eval_stderr
eval_result
eval_timeout
eval_sig_child
)],
],
);
return;
}
lib/App/EvalServer.pm view on Meta::CPAN
my $start_time = time;
my $wheel = POE::Wheel::Run->new(
Program => $CHILD_PROGRAM,
ProgramArgs => [$tempdir, $result_pipe, $jail, $self->{user},
$self->{limit}, $lang, $code, $self->{unsafe}],
Priority => 10,
StdioFilter => POE::Filter::Stream->new(),
StderrFilter => POE::Filter::Stream->new(),
StdinEvent => 'eval_stdin',
StdoutEvent => 'eval_stdout',
StderrEvent => 'eval_stderr',
);
$self->{pid_to_id}{$wheel->PID} = $wheel->ID;
if (defined $stdin) {
$wheel->put($stdin);
}
else {
$wheel->shutdown_stdin();
}
lib/App/EvalServer.pm view on Meta::CPAN
$self->{evals}{$wheel->ID} = {
wheel => $wheel,
pipe_wheel => $result_wheel,
pipe_name => $result_pipe,
client_id => $client_id,
alarm_id => $alarm_id,
tempdir => $tempdir,
start_time => $start_time,
return => {
stdout => '',
stderr => '',
output => '',
},
};
$kernel->sig_child($wheel->PID, 'eval_sig_child');
return;
}
sub eval_stdout {
my ($self, $chunk, $wheel_id) = @_[OBJECT, ARG0, ARG1];
my $eval = $self->{evals}{$wheel_id};
$eval->{return}{stdout} .= $chunk;
$eval->{return}{output} .= $chunk;
return;
}
sub eval_stderr {
my ($self, $chunk, $wheel_id) = @_[OBJECT, ARG0, ARG1];
my $eval = $self->{evals}{$wheel_id};
$eval->{return}{stderr} .= $chunk;
$eval->{return}{output} .= $chunk;
return;
}
sub eval_result {
my ($self, $return, $id) = @_[OBJECT, ARG0, ARG1];
my $wheel_id = delete $self->{pipe_to_id}{$id};
my $eval = $self->{evals}{$wheel_id};
while (my ($key, $value) = each %$return) {
lib/App/EvalServer.pm view on Meta::CPAN
no errors occurred B<before> the code was evaluated, the hash will contain the
following keys:
=over 4
=item * B<'result'>, containing the result of the evaluation.
=item * B<'stdout'>, a string containing everything that was printed to the
evaluating process' stdout handle.
=item * B<'stderr'>, a string containing everything that was printed to the
evaluating process' stderr handle.
=item * B<'output'> a string containing the merged output (stdout & stderr)
from the evaluating process.
=item * B<'memory'>, the memory use of the evaluating process (as reported by
L<C<(getrusage())[2]>|BSD::Resource/getrusage>).
=item * B<'real_time'>, the real time taken by the evaluating process.
=item * B<'user_time'>, the user time taken by the evaluating process.
=item * B<'sys_time'>, the sys time taken by the evaluating process.
( run in 0.256 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )