4
votes

I am trying to run a server with Plack::Runner. How do I run it in the background? I've tried the following:

my $runner = Plack::Runner->new;
$runner->parse_options(qw' --host 127.0.0.1 --port 90210 -D');
$runner->run($app);

It seems to ignore the -D. I've also tried '--daemon' and that doesn't work either.

Thanks!

1
Is there a reason you aren't using plackup or other PSGI servers?Brad Gilbert
The example I found online used Plack::Runner. It's been quite a while since I've used perl in production so if there's another solution then let me know.user_78361084
Usually you would just call plackup --host 127.0.0.1 --port 90210 -D /path/to/app.psgi. For example .psgi files look at the webpage for the Plack distribution there are almost 20 examples.Brad Gilbert

1 Answers

3
votes

What is $app?.

my $runner = Plack::Runner->new;
$runner->parse_options(qw' --host 127.0.0.1 --port 90210 -D');
$runner->run("app.pm"); or "$app"

app.pm is app file or you can try:

my $app = sub {
    return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello World' ] ];
};

This works.