Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

[solved] PAR and Mojolicious

by basiliscos (Monk)
on May 12, 2014 at 18:37 UTC ( #1085820=perlquestion: print w/ replies, xml ) Need Help??
basiliscos has asked for the wisdom of the Perl Monks concerning the following question:

Hello dear monks!

Is it possible to bundle the Mojolicious web-application as single binary executable? I need that for the following purposes:

  1. Easily deliver the ready product to customers, e.g. updates. They'll need just replace the binary file. No headaches with dependencies etc.
  2. As there is come licence checking/validation code, it would be harder to hack/modify it, comparing to regular "vulnerable" for modifications .pm files. I plan even embed the licence information into it.

For that purposes, I have tried App::Staticperl from famous Mark Lehmann, but I have met the following problem:

staticperl mkapp app --boot path/to/my/launcher -M strict.pm -M warnin +gs.pm -MFindBin -M Mojo::Server::Hypnotoad ERROR: Can't open file "/loader/0xc800d0/Mojo/entities.txt": No such f +ile or directory at /loader/0xc800d0/Mojo/Loader.pm line 7. Compilation failed in require at /loader/0xc800d0/Mojo/Loader.pm line +7, <$R_TRACER> line 4. BEGIN failed--compilation aborted at /loader/0xc800d0/Mojo/Loader.pm l +ine 7, <$R_TRACER> line 4. Compilation failed in require at /loader/0xc800d0/Mojo/Server.pm line +5, <$R_TRACER> line 4. BEGIN failed--compilation aborted at /loader/0xc800d0/Mojo/Server.pm l +ine 5, <$R_TRACER> line 4. Compilation failed in require at /loader/0xc800d0/Mojo/Base.pm line 30 +, <$R_TRACER> line 4. BEGIN failed--compilation aborted at /loader/0xc800d0/Mojo/Server/Daem +on.pm line 2, <$R_TRACER> line 4. Compilation failed in require at /loader/0xc800d0/Mojo/Base.pm line 30 +, <$R_TRACER> line 4. BEGIN failed--compilation aborted at /loader/0xc800d0/Mojo/Server/Pref +ork.pm line 2, <$R_TRACER> line 4. Compilation failed in require at /loader/0xc800d0/Mojo/Server/Hypnotoa +d.pm line 9, <$R_TRACER> line 4. BEGIN failed--compilation aborted at /loader/0xc800d0/Mojo/Server/Hypn +otoad.pm line 9, <$R_TRACER> line 4. Compilation failed in require at (eval 4) line 1, <$R_TRACER> line 4. BEGIN failed--compilation aborted at (eval 4) line 1, <$R_TRACER> line + 4. (while loading 'Mojo::Server::Hypnotoad') processing bundle files (try more -v power if you get bored waiting he +re)... generating bundle.h... generating bundle.c... 440353 octets (356853 data octets). ... build app...

Now I'm not even sure, that this is possible. Does anybody have success in similar task? Is there alternative solution for the 2nd goal?

The similar question: I also need to build portable (i.e. which could be just launched from flash-drive without any installation) win32 application with OpenGL support (i.e. something like game). How to do that? Any successful receipts?

Thanks!

Comment on [solved] PAR and Mojolicious
Download Code
Re: staticperl ( and Mojolicious )
by wjw (Curate) on May 12, 2014 at 19:37 UTC
    Not sure if this is what you are after or not, but PAR::Packer seems like it might be worth looking at.

    ...Hope there is something there for you...

    ...the majority is always wrong, and always the last to know about it...
    Insanity: Doing the same thing over and over again and expecting different results...

      Thank you, for hinting on PAR::Packer

      .

      Here is my receipt, how to make Mojolicious::Lite working under PAR::packer. I have taken some ideas from here

      1. You should have the code like the following at the beginning of myapp.pl, before "use Mojolicious::Lite" :

        BEGIN { if(exists $ENV{PAR_TEMP}) { my $dir = $ENV{PAR_TEMP}; chdir $dir; my @substitutions = qw/Mojo Mojolicious/; for(@substitutions){ next if -l; symlink "inc/$_", $_ or die "Can't symlink $_ at $dir: $!"; } print "I'm at at $dir\n"; } }

        NB for Win32 : the directories should be copied instead of just symlink'ed.

      2. Locate the Mojo/entities.txt and Mojolicious/Commands.pm from Mojolicious distribution:

        $ locate entities.txt /home/dmol/development/perl/dev-env.new/perlbrew/perls/perl-5.16.3/lib +/site_perl/5.16.3/Mojo/entities.txt $ locate Commands.pm /home/dmol/development/perl/dev-env.new/perlbrew/perls/perl-5.16.3/lib +/site_perl/5.16.3/Mojolicious/Commands.pm

        (As alternative, you could just point to them somewhere, where Mojolicious disrtibution has being manually unpacked).

      3. Create standalone application via the following command line:

        pp -x -a "/home/dmol/development/perl/dev-env.new/perlbrew/perls/perl- +5.16.3/lib/site_perl/5.16.3/Mojo/entities.txt;Mojo/entities.txt" \ -a "/home/dmol/development/perl/dev-env.new/perlbrew/perls/perl-5.16.3 +/lib/site_perl/5.16.3/Mojolicious/Commands.pm;Mojolicious/Commands.pm +" \ ./myapp.pl

      I haven't tried the application with external public and templates dirs, but probably, you should include them into archive (see pp's help), and may be do the same tricks as in p.1

      I hope it would be useful for somebody!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1085820]
Approved by Laurent_R
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2014-12-26 16:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (172 votes), past polls