1Plack::Runner(3) User Contributed Perl Documentation Plack::Runner(3)
2
3
4
6 Plack::Runner - plackup core
7
9 # Your bootstrap script
10 use Plack::Runner;
11 my $app = sub { ... };
12
13 my $runner = Plack::Runner->new;
14 $runner->parse_options(@ARGV);
15 $runner->run($app);
16
18 Plack::Runner is the core of plackup runner script. You can create your
19 own frontend to run your application or framework, munge command line
20 options and pass that to "run" method of this class.
21
22 "run" method does exactly the same thing as the plackup script does,
23 but one notable addition is that you can pass a PSGI application code
24 reference directly with "--app" option, rather than via ".psgi" file
25 path or with "-e" switch. This would be useful if you want to make an
26 installable PSGI application.
27
28 Also, when "-h" or "--help" switch is passed, the usage text is
29 automatically extracted from your own script using Pod::Usage.
30
32 Do not directly call this module from your ".psgi", since that makes
33 your PSGI application unnecessarily depend on plackup and won't run
34 other backends like Plack::Handler::Apache2 or mod_psgi.
35
36 If you really want to make your ".psgi" runnable as a standalone
37 script, you can do this:
38
39 my $app = sub { ... };
40
41 unless (caller) {
42 require Plack::Runner;
43 my $runner = Plack::Runner->new;
44 $runner->parse_options(@ARGV);
45 return $runner->run($app);
46 }
47
48 return $app;
49
50 WARNING: this section used to recommend "if (__FILE__ eq $0)" but it's
51 known to be broken since Plack 0.9971, since $0 is now always set to
52 the .psgi file path even when you run it from plackup.
53
55 plackup
56
57
58
59perl v5.12.3 2011-06-22 Plack::Runner(3)