use strict;
use warnings;
use Plack::Builder;
use EnsEMBL::REST;
use Config;
use Plack::Util;
use File::Basename;
use File::Spec;
my $app = EnsEMBL::REST->psgi_app;
builder {

  my $dirname = dirname(__FILE__);
  my $rootdir = File::Spec->rel2abs(File::Spec->catdir($dirname, File::Spec->updir(), File::Spec->updir()));
  my $staticdir = File::Spec->catdir($rootdir, 'root');
    Plack::Util::load_class('BSD::Resource') if $Config{osname} eq 'darwin';
    enable 'SizeLimit' => (
        max_unshared_size_in_kb => (300 * 1024),    # 100MB per process (memory assigned just to the process)
        check_every_n_requests => 10,
    );
    enable "Plack::Middleware::ReverseProxy";
    enable 'StackTrace';
    enable 'Runtime';
    enable "ContentLength";
    enable 'CrossOrigin', origins => '*', headers => '*', methods => ['GET','POST','OPTIONS'];
    $app;
}


use strict;
use warnings;
use Plack::Builder;
use EnsEMBL::REST;
use Config;
use Plack::Util;
use File::Basename;
use File::Spec;
my $app = EnsEMBL::REST->psgi_app;
builder {

  my $dirname = dirname(__FILE__);
  my $rootdir = File::Spec->rel2abs(File::Spec->catdir($dirname, File::Spec->updir(), File::Spec->updir()));
  my $staticdir = File::Spec->catdir($rootdir, 'root');
    Plack::Util::load_class('BSD::Resource') if $Config{osname} eq 'darwin';
    enable 'SizeLimit' => (
        max_unshared_size_in_kb => (1300 * 1024),    # 1300MB per process (memory assigned just to the process)
        check_every_n_requests => 10,
        log_when_limits_exceeded => 1
    );
    enable "Plack::Middleware::ReverseProxy";
    enable 'StackTrace';
    enable 'Runtime';
    enable "ContentLength";
    enable 'CrossOrigin', origins => '*', headers => '*', methods => ['GET','POST','OPTIONS'];
    $app;
}


Change configuration for maximum starman worker process memory size
Change configuration for maximum starman worker process memory size

Previously this was 300MB. But the virtual and resident sizes for a single
worker process are both significantly larger. Because we were checking it
every 10 requests, the worker processes were restarted after serving 10
requests.

Change it to 1300MB so that it is slightly larger than the virtual size for
a single worker which is 1260MB minimum.
