mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-08 03:40:42 -04:00
Merge branch 'master' of github.com:simcop2387/perlbuut
Conflicts: bin/evalserver
This commit is contained in:
commit
bd17879ca3
4 changed files with 11948 additions and 8349 deletions
|
@ -1,5 +1,6 @@
|
||||||
#!/home/ryan/perl5/perlbrew/perls/perl-5.14.1/bin/perl
|
#!/home/ryan/perl5/perlbrew/perls/perl-5.14.1/bin/perl
|
||||||
|
|
||||||
|
#use local::lib;
|
||||||
# Guess we're being activated inside bin/, so go up a directory.
|
# Guess we're being activated inside bin/, so go up a directory.
|
||||||
BEGIN { if( not -e 'lib' and not -e 'etc' and -e 'bb3' ) { chdir ".."; } }
|
BEGIN { if( not -e 'lib' and not -e 'etc' and -e 'bb3' ) { chdir ".."; } }
|
||||||
|
|
||||||
|
@ -8,7 +9,7 @@ use lib "$FindBin::Bin/../lib";
|
||||||
use EvalServer;
|
use EvalServer;
|
||||||
use POSIX qw/setsid/;
|
use POSIX qw/setsid/;
|
||||||
|
|
||||||
$ENV{PATH}="/usr/bin/:/bin/";
|
$ENV{PATH}="/home/farnsworth/perl5/perlbrew/perls/perl-5.14.0/bin:/usr/bin/:/bin/";
|
||||||
|
|
||||||
# Only daemonize if we're asked to.
|
# Only daemonize if we're asked to.
|
||||||
if( $ARGV[0] eq '-d' ) {
|
if( $ARGV[0] eq '-d' ) {
|
||||||
|
|
20022
deps/env.js
vendored
20022
deps/env.js
vendored
File diff suppressed because one or more lines are too long
|
@ -42,7 +42,7 @@ sub spawn_eval {
|
||||||
}
|
}
|
||||||
warn "Spawning Eval: $args->{code}\n";
|
warn "Spawning Eval: $args->{code}\n";
|
||||||
my $wheel = POE::Wheel::Run->new(
|
my $wheel = POE::Wheel::Run->new(
|
||||||
Program => [ 'perl', $filename ],
|
Program => [ '/home/farnsworth/perl5/perlbrew/perls/perl-5.14.0/bin/perl', $filename ],
|
||||||
ProgramArgs => [ ],
|
ProgramArgs => [ ],
|
||||||
|
|
||||||
CloseOnCall => 1, #Make sure all of the filehandles are closed.
|
CloseOnCall => 1, #Make sure all of the filehandles are closed.
|
||||||
|
|
44
lib/eval.pl
44
lib/eval.pl
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/perl
|
#!/home/farnsworth/perl5/perlbrew/perls/perl-5.14.0/bin/perl
|
||||||
|
|
||||||
use lib '/home/farnsworth/perl5/lib/perl5/x86_64-linux-gnu-thread-multi';
|
use lib '/home/farnsworth/perl5/lib/perl5/x86_64-linux-gnu-thread-multi';
|
||||||
use lib '/home/farnsworth/perl5/lib/perl5';
|
use lib '/home/farnsworth/perl5/lib/perl5';
|
||||||
|
@ -15,10 +15,13 @@ use List::MoreUtils;
|
||||||
use List::UtilsBy;
|
use List::UtilsBy;
|
||||||
use Data::Munge;
|
use Data::Munge;
|
||||||
use Scalar::MoreUtils;
|
use Scalar::MoreUtils;
|
||||||
|
use Regexp::Common;
|
||||||
|
use Encode;
|
||||||
|
|
||||||
require Moose;
|
require Moose;
|
||||||
require MooseX::Declare;
|
require MooseX::Declare;
|
||||||
eval "use MooseX::Declare; class Foo { has dongs => ( is => ro, isa => 'Int' ); };";
|
eval "use MooseX::Declare; class Foo { has dongs => ( is => ro, isa => 'Int' ); };";
|
||||||
|
require "utf8_heavy.pl";
|
||||||
|
|
||||||
no warnings;
|
no warnings;
|
||||||
|
|
||||||
|
@ -52,7 +55,7 @@ use Text::ParseWords;
|
||||||
use B::Deparse;
|
use B::Deparse;
|
||||||
|
|
||||||
# Javascript Libs
|
# Javascript Libs
|
||||||
BEGIN{ eval "use JavaScript::SpiderMonkey;"; }
|
BEGIN{ eval "use JavaScript::V8; use JSON::XS; JavaScript::V8::Context->new()->eval('1')"; }
|
||||||
my $JSENV_CODE = do { local $/; open my $fh, "deps/env.js"; <$fh> };
|
my $JSENV_CODE = do { local $/; open my $fh, "deps/env.js"; <$fh> };
|
||||||
require 'bytes_heavy.pl';
|
require 'bytes_heavy.pl';
|
||||||
|
|
||||||
|
@ -60,6 +63,7 @@ use Tie::Hash::NamedCapture;
|
||||||
|
|
||||||
{#no warnings 'constant';
|
{#no warnings 'constant';
|
||||||
uc "\x{666}"; #Attempt to load unicode libraries.
|
uc "\x{666}"; #Attempt to load unicode libraries.
|
||||||
|
lc "JONQUIÉRE";
|
||||||
}
|
}
|
||||||
binmode STDOUT, ":utf8"; # Enable utf8 output.
|
binmode STDOUT, ":utf8"; # Enable utf8 output.
|
||||||
|
|
||||||
|
@ -145,6 +149,8 @@ use Storable qw/nfreeze/; nfreeze([]); #Preload Nfreeze since it's loaded on dem
|
||||||
my $limit = 150 * $meg;
|
my $limit = 150 * $meg;
|
||||||
|
|
||||||
(
|
(
|
||||||
|
setrlimit(RLIMIT_VMEM, 1024*$meg, 1024*$meg)
|
||||||
|
and
|
||||||
setrlimit(RLIMIT_DATA, $limit, $limit )
|
setrlimit(RLIMIT_DATA, $limit, $limit )
|
||||||
and
|
and
|
||||||
setrlimit(RLIMIT_STACK, $limit, $limit )
|
setrlimit(RLIMIT_STACK, $limit, $limit )
|
||||||
|
@ -161,8 +167,6 @@ use Storable qw/nfreeze/; nfreeze([]); #Preload Nfreeze since it's loaded on dem
|
||||||
and
|
and
|
||||||
setrlimit(RLIMIT_AS,$limit,$limit)
|
setrlimit(RLIMIT_AS,$limit,$limit)
|
||||||
and
|
and
|
||||||
setrlimit(RLIMIT_VMEM,$limit, $limit)
|
|
||||||
and
|
|
||||||
setrlimit(RLIMIT_MEMLOCK,100,100)
|
setrlimit(RLIMIT_MEMLOCK,100,100)
|
||||||
and
|
and
|
||||||
setrlimit(RLIMIT_CPU, 10,10)
|
setrlimit(RLIMIT_CPU, 10,10)
|
||||||
|
@ -244,38 +248,22 @@ use Storable qw/nfreeze/; nfreeze([]); #Preload Nfreeze since it's loaded on dem
|
||||||
my( $code ) = @_;
|
my( $code ) = @_;
|
||||||
local $@;
|
local $@;
|
||||||
|
|
||||||
my $js = JavaScript::SpiderMonkey->new;
|
my $js = JavaScript::V8::Context->new;
|
||||||
$js->init;
|
|
||||||
# This is great evil!
|
|
||||||
JavaScript::SpiderMonkey::JS_ForceLatest( $js->{context} );
|
|
||||||
|
|
||||||
|
|
||||||
# Set up the Environment for ENVJS
|
# Set up the Environment for ENVJS
|
||||||
$js->property_by_path("Envjs.profile", 0);
|
$js->bind("print", sub { print @_ } );
|
||||||
$js->function_set("print", sub { print @_ } );
|
$js->bind("write", sub { print @_ } );
|
||||||
|
|
||||||
for( qw/log debug info warn error/ ) {
|
# for( qw/log debug info warn error/ ) {
|
||||||
$js->eval("Envjs.$_=function(x){}");
|
# $js->eval("Envjs.$_=function(x){}");
|
||||||
}
|
# }
|
||||||
|
|
||||||
$js->eval($JSENV_CODE) or die $@;
|
$js->eval($JSENV_CODE) or die $@;
|
||||||
|
|
||||||
|
my $out = eval { $js->eval($code) };
|
||||||
|
|
||||||
my $modified_code = qq!
|
|
||||||
var ret = eval("\Q$code\E");
|
|
||||||
if( ret === null ) {
|
|
||||||
"null"
|
|
||||||
}
|
|
||||||
else if( typeof ret == "object" || typeof ret == "array" ) {
|
|
||||||
ret.toSource();
|
|
||||||
}
|
|
||||||
else { ret }
|
|
||||||
!;
|
|
||||||
|
|
||||||
print $js->ret_eval($modified_code);
|
|
||||||
|
|
||||||
if( $@ ) { print "ERROR: $@"; }
|
if( $@ ) { print "ERROR: $@"; }
|
||||||
|
else { print encode_json $out }
|
||||||
}
|
}
|
||||||
|
|
||||||
sub ruby_code {
|
sub ruby_code {
|
||||||
|
|
Loading…
Add table
Reference in a new issue