PAX
view release on metacpan or search on metacpan
lib/PAX/AppImage.pm view on Meta::CPAN
mkdir($asset_root, 0700);
for (unsigned long i = 0; i < pax_asset_count; i++) {
char path[4096];
snprintf(path, sizeof(path), "%s/%s", $asset_root, pax_assets[i].path);
ensure_parent_dirs(path);
FILE *out = fopen(path, "wb");
if (!out) continue;
fwrite(pax_assets[i].data, 1, pax_assets[i].len, out);
fclose(out);
}
setenv("PAX_EMBEDDED_ASSET_ROOT", $asset_root, 1);
}
static void json_string(FILE *out, const char *s) {
fputc('"', out);
for (; *s; s++) {
if (*s == '"' || *s == '\\\\') { fputc('\\\\', out); fputc(*s, out); }
else if (*s == '\\n') fputs("\\\\n", out);
else fputc(*s, out);
}
fputc('"', out);
lib/PAX/CodeUnitCompiler.pm view on Meta::CPAN
}
if ($body =~ /\A\s*require\s+([A-Za-z_][A-Za-z0-9_:]*)\s*;\s*print\s+\$([A-Za-z_][A-Za-z0-9_:]*)::([A-Za-z_][A-Za-z0-9_]*)\s*,\s*"\\n"\s*;\s*exit\s+(\d+)\s*;\s*\z/s) {
return {
op => 'print_required_global',
require_module => $1,
symbol => $2 . '::' . $3,
newline => 1,
exit_code => 0 + $4,
};
}
if ($body =~ /\APAX_EMBEDDED_ASSET_ROOT/ || $body =~ /\$ENV\{PAX_EMBEDDED_ASSET_ROOT\}/) {
return {
op => 'print_embedded_asset',
logical_path => 'banner.txt',
} if $body =~ /banner\.txt/;
}
return;
}
sub _compile_dispatch_unknown_action {
my ($body) = @_;
lib/PAX/Gatekeeper.pm view on Meta::CPAN
push @missing, 'paxfile_loader' if !-f "$self->{root}/lib/PAX/Paxfile.pm";
push @missing, 'project_paxfile' if !-f "$self->{root}/paxfile.yml";
push @missing, 'app_image_test' if !-f "$self->{root}/t/app_image.t";
push @missing, 'embedded_asset_fixture' if !-f "$self->{root}/t/fixtures/app_assets/banner.txt";
my $cli = _slurp("$self->{root}/lib/PAX/CLI.pm");
my $app_image = _slurp("$self->{root}/lib/PAX/AppImage.pm");
push @missing, 'public_build_command' if $cli !~ /if \(\$command eq 'build'\)/;
push @missing, 'public_run_command' if $cli !~ /if \(\$command eq 'run'\)/;
push @missing, 'asset_build_flags' if $cli !~ /--asset/ || $cli !~ /--asset-dir/;
push @missing, 'paxfile_cli_flags' if $cli !~ /--paxfile/ || $cli !~ /--no-paxfile/;
push @missing, 'asset_embedding_runtime' if $app_image !~ /pax_assets/ || $app_image !~ /PAX_EMBEDDED_ASSET_ROOT/;
return {
id => 'whole_program_app_image_runtime',
description => 'Whole-program Perl entrypoints can be built from paxfile.yml into PAX app images with embedded assets and run through a preloaded subsystem',
status => @missing ? 'blocked' : 'passed',
evidence => @missing ? 'missing: ' . join(', ', @missing) : 'PAX::AppImage/PAX::AppServer',
};
}
sub _check_benchmark_matrix_command {
my ($self) = @_;
lib/PAX/StandaloneDispatch.pm view on Meta::CPAN
my $script = q{
my ($entry, $region, $left, $right) = @ARGV;
require PAX::StandaloneRuntime;
my $rv = PAX::StandaloneRuntime->run(entrypoint => $entry, argv => []);
my $qualified = $region =~ /::/ ? $region : "main::$region";
no strict 'refs';
my $value = &{$qualified}(0 + $left, 0 + $right);
print defined $value ? $value : q{};
};
local $ENV{PERL5LIB} = $paths->{perl5lib} if defined $paths->{perl5lib} && length $paths->{perl5lib};
local $ENV{PAX_EMBEDDED_ASSET_ROOT} = $paths->{assets_root};
local $ENV{PAX_STANDALONE_MANIFEST_PATH} = $paths->{manifest_path};
local $ENV{PAX_STANDALONE_TMPDIR} = $paths->{extract_dir};
my $err = gensym;
my $pid = open3(my $in, my $out, $err, $perl, '-e', $script, $paths->{entrypoint}, $region->{region_name}, $args{left}, $args{right});
close $in;
local $/;
my $stdout = <$out> // '';
my $stderr = <$err> // '';
waitpid($pid, 0);
lib/PAX/StandaloneImage.pm view on Meta::CPAN
char top[4096];
if (snprintf(top, sizeof(top), "%s/%s", code_root, pax_code_lib_roots[i]) >= (int)sizeof(top)) return 111;
if (append_path(libpath, lib_size, top) != 0) return 111;
}
for (unsigned long i = 0; i < pax_runtime_inc_roots_count; i++) {
char top[4096];
if (snprintf(top, sizeof(top), "%s/%s", runtime_root, pax_runtime_inc_roots[i]) >= (int)sizeof(top)) return 111;
if (append_path(libpath, lib_size, top) != 0) return 111;
}
setenv("PAX_EMBEDDED_ASSET_ROOT", asset_root, 1);
setenv("PAX_STANDALONE_TMPDIR", tmpdir, 1);
setenv("PAX_STANDALONE_MANIFEST_PATH", manifest_path, 1);
if (access(runtime_lib_root, F_OK) == 0) {
const char *old_ld = getenv("LD_LIBRARY_PATH");
char merged_ld[16384];
if (old_ld && *old_ld) snprintf(merged_ld, sizeof(merged_ld), "%s:%s", runtime_lib_root, old_ld);
else snprintf(merged_ld, sizeof(merged_ld), "%s", runtime_lib_root);
setenv("LD_LIBRARY_PATH", merged_ld, 1);
}
return 0;
lib/PAX/StandaloneRuntime.pm view on Meta::CPAN
$host = shift @ARGV // die "--host requires a value\n";
next;
}
if ($arg eq '--port') {
$port = shift @ARGV // die "--port requires a value\n";
next;
}
die "unexpected argument: $arg\n";
}
my $asset_root = $ENV{PAX_EMBEDDED_ASSET_ROOT}
|| File::Spec->catdir(dirname(_virtual_entrypoint_path($entrypoint)), '..', 'share');
my $builder_method = $record->{builder_method} || 'build_psgi_app';
my $app_module = $record->{app_module} || die "service dispatch missing app module\n";
my $server_module = $record->{server_module} || die "service dispatch missing server module\n";
my $app = $app_module->$builder_method(asset_root => $asset_root);
my $server = $server_module->new;
$server->run($app, {
host => $host,
port => $port,
listen => ["$host:$port"],
lib/PAX/StandaloneRuntime.pm view on Meta::CPAN
if ($op eq 'print_required_global') {
my $module = $action->{require_module} // die 'dispatch require module missing';
_load_package_by_module_name($module);
no strict 'refs';
my $value = ${ $action->{symbol} };
print $value;
print "\n" if $action->{newline};
exit($action->{exit_code} // 0);
}
if ($op eq 'print_embedded_asset') {
my $root = $ENV{PAX_EMBEDDED_ASSET_ROOT} // '';
my $logical = $action->{logical_path} // die 'dispatch asset logical path missing';
my $path = $root ? File::Spec->catfile($root, split m{/}, $logical) : '';
if (!$path || !-f $path) {
print STDERR "missing asset\n";
exit 3;
}
open my $fh, '<', $path or die $!;
local $/;
my $content = <$fh>;
close $fh;
t/fixtures/app_entry.pl view on Meta::CPAN
use ResidualOnly ();
use SlowLoad ();
my $cmd = shift @ARGV // 'status';
if ($cmd eq 'status') {
print SlowLoad::message(), "\n";
exit 0;
}
if ($cmd eq 'asset') {
my $root = $ENV{PAX_EMBEDDED_ASSET_ROOT} // '';
my $path = $root ? "$root/banner.txt" : '';
if (!$path || !-f $path) {
print STDERR "missing asset\n";
exit 3;
}
open my $fh, '<', $path or die $!;
my $content = <$fh>;
close $fh;
print $content;
exit 0;
( run in 2.768 seconds using v1.01-cache-2.11-cpan-71847e10f99 )