PAX
view release on metacpan or search on metacpan
lib/PAX/AppServer.pm view on Meta::CPAN
my $pid = fork();
if (!defined $pid) {
print {$client} "fork failed: $!\n__PAX_EXIT__:111\n";
return;
}
if ($pid == 0) {
open STDOUT, '>&', $client;
open STDERR, '>&', $client;
my $cwd = $request->{cwd} // '.';
chdir $cwd if -d $cwd;
local @ARGV = @{ $request->{argv} // [] };
local $0 = $image->{entrypoint};
$ENV{PAX_APP_IMAGE} = $image->{name};
my $ok = do $image->{entrypoint};
if (!$ok) {
print STDERR defined $@ && length $@ ? $@ : "failed to run $image->{entrypoint}: $!\n";
exit 111;
}
exit 0;
}
waitpid($pid, 0);
lib/PAX/CLI.pm view on Meta::CPAN
return 0 if !defined $candidate || $candidate eq q{};
return 0 if $candidate =~ /\A-/;
return -f $candidate ? 1 : 0;
}
# Execute a shebang-target script as package main while preserving the expected
# process-facing script path and argument vector.
sub _run_interpreter_script {
my ($class, $script, @argv) = @_;
my $script_path = File::Spec->rel2abs($script);
local @ARGV = @argv;
local $0 = $script_path;
require FindBin;
local $FindBin::Bin;
local $FindBin::RealBin;
local $FindBin::Script;
local $FindBin::RealScript;
FindBin::again();
my $runner = sub {
package main;
lib/PAX/Capture.pm view on Meta::CPAN
name => $full,
available => JSON::PP::false(),
reason => "$@",
};
}
}
return \@subs;
}
my $ok = eval {
local @ARGV = ();
require File::Spec;
open my $null_out, '>', File::Spec->devnull() or die "cannot open devnull: $!";
open my $null_err, '>', File::Spec->devnull() or die "cannot open devnull: $!";
local *STDOUT = $null_out;
local *STDERR = $null_err;
do $entrypoint;
die $@ if $@;
1;
};
lib/PAX/StandaloneRuntime.pm view on Meta::CPAN
my @argv = @{ $args{argv} // \@ARGV };
my $self_path = _standalone_executable_path();
_install_namespace_compat();
_install_require_hook();
_install_pending_wrappers();
local $0 = $self_path if defined $self_path && $self_path ne '';
if (@argv && $argv[0] eq '--pax-standalone-helper') {
shift @argv;
my $helper = shift @argv // die "standalone helper name required\n";
local @ARGV = @argv;
return _run_standalone_managed_helper($helper, @argv);
}
local @ARGV = @argv;
my $rv = _run_entrypoint($entrypoint);
_install_pending_wrappers();
return $rv;
}
sub _entrypoint_looks_valid {
my ($entrypoint) = @_;
return 0 if !defined $entrypoint;
return 0 if $entrypoint =~ /\A-/;
lib/PAX/StandaloneRuntime.pm view on Meta::CPAN
$source = $core_source;
$path = $core_path;
@helper_argv = @argv;
unshift @helper_argv, $helper if $helper ne '_dashboard-core';
}
else {
$source = $helper_source;
$path = $helper_path;
@helper_argv = @argv;
}
local @ARGV = @helper_argv;
local $0 = $path if defined $path && $path ne '';
my $wrapped = "package main;\n#line 1 \"$path\"\n" . $source;
my $rv = eval $wrapped;
die $@ if $@;
return 0 if !defined $rv;
return $rv;
}
sub _direct_standalone_helper_name_from_path {
my ($path) = @_;
t/standalone_runtime.t view on Meta::CPAN
return;
} if $name eq 'main::_skill_dotted_command_parts';
return sub {
$switchboard_calls++;
die 'switchboard path should not run';
} if $name eq 'main::_exec_switchboard_command';
return;
};
{
local @ARGV = ('ps1', '--jobs', '1');
my $rv = PAX::StandaloneRuntime::_run_cli_router_unit($entrypoint);
is($rv, 'direct-helper', 'cli router routes built-in helper commands through the standalone helper fast path');
}
{
local @ARGV = ('sample-skill.run-test', '--verbose');
my $rv = PAX::StandaloneRuntime::_run_cli_router_unit($entrypoint);
is($rv, 'direct-helper', 'cli router routes dotted skill commands through the standalone helper fast path');
}
is_deeply(
\@helper_calls,
[
['ps1', '--jobs', '1'],
['skills', '_exec', 'sample-skill', 'run-test', '--verbose'],
],
( run in 2.016 seconds using v1.01-cache-2.11-cpan-ceb78f64989 )