Skip to content

Commit

Permalink
Item14152: Merge commit 'd48bdb3e52f1c1df6f158dcf493ad17144333145' in…
Browse files Browse the repository at this point in the history
…to Item14152

* commit 'd48bdb3e52f1c1df6f158dcf493ad17144333145':
  Item13897: Fixing the previous commit.
  Item13897: Added support for serving static files.
  • Loading branch information
vrurg committed Sep 19, 2016
2 parents 698f70a + d48bdb3 commit 8151e0d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 14 deletions.
30 changes: 29 additions & 1 deletion core/bin/foswiki.psgi
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
#!/usr/bin/env perl
# See bottom of file for license and copyright information
use v5.14;
use Cwd;
use lib Cwd::abs_path("../lib");
use File::Spec;

my $root;

BEGIN {
$root = $ENV{FOSWIKI_HOME};
if ( !$root ) {

# Try to guess our root dir by looking into %INC
my $incKey = ( grep { /\/foswiki.*\.psgi$/ } keys %INC )[0];
my $scriptFile = $INC{$incKey};
my ( $volume, $scriptDir ) = File::Spec->splitpath($scriptFile);
$root =
File::Spec->catpath( $volume,
File::Spec->catdir( $scriptDir, File::Spec->updir ), "" );
}

push @INC, File::Spec->catdir( $root, "lib" );
}

use Plack::Builder;
use Foswiki::App;

my $app = sub {
return Foswiki::App->run( env => shift, );
};

builder {
enable 'Plack::Middleware::Static',
path => qr/^\/pub\//,
root => $root;
$app;
}
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Expand Down
46 changes: 33 additions & 13 deletions core/bin/foswiki_debug.psgi
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
#!/usr/bin/env perl
# See bottom of file for license and copyright information
use v5.14;
use Cwd;
use lib Cwd::abs_path("../lib"),
( $ENV{FOSWIKI_HOME} ? $ENV{FOSWIKI_HOME} . "/lib" : () );
use File::Spec;
use Data::Dumper;

my $root;

BEGIN {
$root = $ENV{FOSWIKI_HOME};
if ( !$root ) {

# Try to guess our root dir by looking into %INC
my $incKey = ( grep { /\/foswiki.*\.psgi$/ } keys %INC )[0];
my $scriptFile = $INC{$incKey};
my ( $volume, $scriptDir ) = File::Spec->splitpath($scriptFile);
$root =
File::Spec->catpath( $volume,
File::Spec->catdir( $scriptDir, File::Spec->updir ), "" );
}

push @INC, File::Spec->catdir( $root, "lib" );
}
use Plack::Builder;
use Foswiki::App;
use HTTP::Server::PSGI;
use Devel::Leak;
use Devel::Leak::Object;

use constant CHECKLEAK => 0;

Expand All @@ -19,30 +40,29 @@ BEGIN {

my $app = sub {
my $env = shift;

Devel::Leak::Object::checkpoint if CHECKLEAK;

my $rc = Foswiki::App->run( env => $env, );

if (CHECKLEAK) {
Devel::Leak::Object::status;
eval {
require Devel::MAT::Dumper;
Devel::MAT::Dumper::dump(
$starting_root . "/working/logs/foswiki_debug_psgi.pmat" );
$root . "/working/logs/foswiki_debug_psgi.pmat" );
};
}

return $rc;
};

my $server = HTTP::Server::PSGI->new(
host => "127.0.0.1",
port => 5000,
timeout => 120,
);

$server->run($app);
builder {
enable 'Plack::Middleware::Static',
path => qr/^\/pub\//,
root => $root;
$app;
};
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Expand Down

0 comments on commit 8151e0d

Please sign in to comment.