source: main/trunk/greenstone2/perllib/cpan/Mojolicious/Command/daemon.pm@ 32205

Last change on this file since 32205 was 32205, checked in by ak19, 6 years ago

First set of commits to do with implementing the new 'paged_html' output option of PDFPlugin that uses using xpdftools' new pdftohtml. So far tested only on Linux (64 bit), but things work there so I'm optimistically committing the changes since they work. 2. Committing the pre-built Linux binaries of XPDFtools for both 32 and 64 bit built by the XPDF group. 2. To use the correct bitness variant of xpdftools, setup.bash now exports the BITNESS env var, consulted by gsConvert.pl. 3. All the perl code changes to do with using xpdf tools' pdftohtml to generate paged_html and feed it in the desired form into GS(3): gsConvert.pl, PDFPlugin.pm and its parent ConvertBinaryPFile.pm have been modified to make it all work. xpdftools' pdftohtml generates a folder containing an html file and a screenshot for each page in a PDF (as well as an index.html linking to each page's html). However, we want a single html file that contains each individual 'page' html's content in a div, and need to do some further HTML style, attribute and structure modifications to massage the xpdftool output to what we want for GS. In order to parse and manipulate the HTML 'DOM' to do this, we're using the Mojo::DOM package that Dr Bainbridge found and which he's compiled up. Mojo::DOM is therefore also committed in this revision. Some further changes and some display fixes are required, but need to check with the others about that.

File size: 3.8 KB
Line 
1package Mojolicious::Command::daemon;
2use Mojo::Base 'Mojolicious::Command';
3
4use Mojo::Server::Daemon;
5use Mojo::Util 'getopt';
6
7has description => 'Start application with HTTP and WebSocket server';
8has usage => sub { shift->extract_usage };
9
10sub run {
11 my ($self, @args) = @_;
12
13 my $daemon = Mojo::Server::Daemon->new(app => $self->app);
14 getopt \@args,
15 'b|backlog=i' => sub { $daemon->backlog($_[1]) },
16 'c|clients=i' => sub { $daemon->max_clients($_[1]) },
17 'i|inactivity-timeout=i' => sub { $daemon->inactivity_timeout($_[1]) },
18 'l|listen=s' => \my @listen,
19 'p|proxy' => sub { $daemon->reverse_proxy(1) },
20 'r|requests=i' => sub { $daemon->max_requests($_[1]) };
21
22 $daemon->listen(\@listen) if @listen;
23 $daemon->run;
24}
25
261;
27
28=encoding utf8
29
30=head1 NAME
31
32Mojolicious::Command::daemon - Daemon command
33
34=head1 SYNOPSIS
35
36 Usage: APPLICATION daemon [OPTIONS]
37
38 ./myapp.pl daemon
39 ./myapp.pl daemon -m production -l http://*:8080
40 ./myapp.pl daemon -l http://127.0.0.1:8080 -l https://[::]:8081
41 ./myapp.pl daemon -l 'https://*:443?cert=./server.crt&key=./server.key'
42 ./myapp.pl daemon -l http+unix://%2Ftmp%2Fmyapp.sock
43
44 Options:
45 -b, --backlog <size> Listen backlog size, defaults to
46 SOMAXCONN
47 -c, --clients <number> Maximum number of concurrent
48 connections, defaults to 1000
49 -h, --help Show this summary of available options
50 --home <path> Path to home directory of your
51 application, defaults to the value of
52 MOJO_HOME or auto-detection
53 -i, --inactivity-timeout <seconds> Inactivity timeout, defaults to the
54 value of MOJO_INACTIVITY_TIMEOUT or 15
55 -l, --listen <location> One or more locations you want to
56 listen on, defaults to the value of
57 MOJO_LISTEN or "http://*:3000"
58 -m, --mode <name> Operating mode for your application,
59 defaults to the value of
60 MOJO_MODE/PLACK_ENV or "development"
61 -p, --proxy Activate reverse proxy support,
62 defaults to the value of
63 MOJO_REVERSE_PROXY
64 -r, --requests <number> Maximum number of requests per
65 keep-alive connection, defaults to 100
66
67=head1 DESCRIPTION
68
69L<Mojolicious::Command::daemon> starts applications with the
70L<Mojo::Server::Daemon> backend.
71
72This is a core command, that means it is always enabled and its code a good
73example for learning to build new commands, you're welcome to fork it.
74
75See L<Mojolicious::Commands/"COMMANDS"> for a list of commands that are
76available by default.
77
78=head1 ATTRIBUTES
79
80L<Mojolicious::Command::daemon> inherits all attributes from
81L<Mojolicious::Command> and implements the following new ones.
82
83=head2 description
84
85 my $description = $daemon->description;
86 $daemon = $daemon->description('Foo');
87
88Short description of this command, used for the command list.
89
90=head2 usage
91
92 my $usage = $daemon->usage;
93 $daemon = $daemon->usage('Foo');
94
95Usage information for this command, used for the help screen.
96
97=head1 METHODS
98
99L<Mojolicious::Command::daemon> inherits all methods from
100L<Mojolicious::Command> and implements the following new ones.
101
102=head2 run
103
104 $daemon->run(@ARGV);
105
106Run this command.
107
108=head1 SEE ALSO
109
110L<Mojolicious>, L<Mojolicious::Guides>, L<https://mojolicious.org>.
111
112=cut
Note: See TracBrowser for help on using the repository browser.