Skip to content

Commit

Permalink
Restoring plack mem control.
Browse files Browse the repository at this point in the history
  • Loading branch information
lemming552 committed Feb 2, 2016
1 parent 151d281 commit 982c914
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
18 changes: 18 additions & 0 deletions bin/lacuna.psgi
Expand Up @@ -42,6 +42,24 @@ my $gameover = [ 500,
];

my $app = builder {
unless ($^O eq 'darwin') {
##Wrapper to fully enable size limiting. The psgix.harakiri has to be set for it to work.
enable sub {
my $app = shift;
return sub {
my ($env) = @_;
$env->{'psgix.harakiri'} = 1;
return $app->($env);
}
};
enable "Plack::Middleware::SizeLimit" => (
max_unshared_size_in_kb => '51200', # 50MB
# min_shared_size_in_kb => '8192', # 8MB
max_process_size_in_kb => '125000', # 125MB
check_every_n_requests => 3
);
enable "Plack::Middleware::LightProfile";
}
enable 'CrossOrigin',
origins => '*', methods => ['GET', 'POST'], max_age => 60*60*24*30, headers => '*';

Expand Down
33 changes: 33 additions & 0 deletions t/middleware/lightprofiler.t
@@ -0,0 +1,33 @@
use lib '/data/Lacuna-Server/lib';

use Test::More;
use Log::Any::Test;
use Log::Any qw/$log/;

use Plack::Builder;
use Plack::Test;
use HTTP::Request::Common;

use_ok 'Plack::Middleware::LightProfile';

my $base_app = sub { return [ 200, [], ['Body'] ]; };

my $app = builder {
enable 'LightProfile';
$base_app;
};

test_psgi
app => $app,
client => sub {
my $cb = shift;
my $res = $cb->(GET "/");
is $res->code, 200, 'Call succeeded';
is $res->content, 'Body', '... returned correct content';
}
;

$log->contains_ok(qr/response time: \d.\d+ end memory: \d+ added memory: \d+/, 'Logged memory and time data');
$log->empty_ok('Only one message in the log');

done_testing;

0 comments on commit 982c914

Please sign in to comment.