Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Mojolicious::Lite and PAR::Packer

by frazap (Monk)
on Apr 05, 2019 at 07:06 UTC ( [id://1232177]=perlquestion: print w/replies, xml ) Need Help??

frazap has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to pp @ppopts.txt -o test.exe test.pl

With test.pl being

use Mojolicious::Lite; use File::Spec; BEGIN { if(exists $ENV{PAR_TEMP}) { my $dir = File::Spec->catfile($ENV{PAR_TEMP}, 'inc'); chdir $dir or die "chdir `$dir' failed: $!"; push @ARGV, qw( daemon -m production -l http://127.0.0.1:3000 ); } } my $config = plugin 'Config' =>{file => './test.conf'}; get '/test'; if(exists $ENV{PAR_TEMP} && $^O eq "MSWin32") { system qw(start http://localhost:3000); } app->start; __DATA__ @@ test.html.ep <!DOCTYPE html> <html> <head><title><%=config->{text}%></title></head> <body> <h1><%=config->{text}%></h1> </body> </html>
And ppopts.txt :
-l libeay32_.dll -l zlib1_.dll -l ssleay32_.dll -a 'test.conf;script/test.conf' -M Mojolicious::Plugin::**

Run as morbo test.pl, the page is displayed ok.

I would like to pack this, including the config file, but the exe failed with Configuration file "U:\docs ... \mojo\script\test.conf" missing ...

There is no mojo\script folder on my disc.

How can I pass my config file properly to get it working with pp ?

Thanks !

frazap

Edit: Forgot the config file:
{ text=>'Hello there', }

Replies are listed 'Best First'.
Re: Mojolicious::Lite and PAR::Packer
by Anonymous Monk on Apr 05, 2019 at 09:19 UTC
    Read about -a option for pp
      I did -a 'test.conf;script/test.conf' in the call to pp: so my config file is in the script dir in the par archive. But it is not found there... it is searched in the file system not in the par archive.

      I did try -a 'test.conf' that placed the file in the root folder of the archive but that didn't work either.

      If I add

      my $file; if ( $ENV{PAR_TEMP} ) { print $ENV{PAR_TEMP}, "\n"; $file = $ENV{PAR_TEMP} . "/inc/script/test.conf"; } else { $file = 'test.conf'; } my $config = plugin 'Config' => { file => $file };

      That seems to pass. But I still got errors with

      push @ARGV, qw( daemon -m production -l http://127.0.0.1:3000 );
      That gives "Unknown command "daemon", ...". If I change to
      push @ARGV, qw( $0 daemon -m production -l http://127.0.0.1:3000 );

      That gives "Can't open Mojolicious/Commands.pm: No such file or directory at Mojo/Util.pm line 140"

      Adding -M Mojolicious::Commands in the pp option does nothing.

      I would like to run pp with the -x option but how is is feasible with Mojolicous::Lite ?

        Got it...

        with pp options:

        -l libeay32_.dll -l zlib1_.dll -l ssleay32_.dll -a 'test.conf;script/test.conf' -M Mojolicious::Plugin::** -M Mojolicious::** -M Mojo::**
        and the script
        use Mojolicious::Lite; use File::Spec; BEGIN { if(exists $ENV{PAR_TEMP}) { my $dir = File::Spec->catfile($ENV{PAR_TEMP}, 'inc'); chdir $dir or die "chdir `$dir' failed: $!"; push @ARGV, qw( daemon -m production -l http://127.0.0.1:3000 ); } } my $file; if ( $ENV{PAR_TEMP} ) { print $ENV{PAR_TEMP}, "\n"; $file = $ENV{PAR_TEMP} . "/inc/script/test.conf"; } else { $file = 'test.conf'; } my $config = plugin 'Config' => { file => $file }; get '/test'; if(exists $ENV{PAR_TEMP} && $^O eq "MSWin32") { system qw(start http://localhost:3000/test); } app->start; __DATA__ @@ test.html.ep <!DOCTYPE html> <html> <head><title><%=config->{text}%></title></head> <body> <h1><%=config->{text}%></h1> </body> </html>

        The packed archive works

        frazap

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1232177]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-29 10:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found