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