Skip to content

Commit

Permalink
improved Mojo::Server to load applications consistently for all serve…
Browse files Browse the repository at this point in the history
…rs (closes #686)
  • Loading branch information
kraih committed Oct 8, 2014
1 parent 70bbe92 commit 88017f3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changes
@@ -1,6 +1,8 @@

5.49 2014-10-09
- Improved form content generator to allow custom content types.
- Improved Mojo::Server to load applications consistently for all servers.
(tianon, sri)

5.48 2014-10-07
- Emergency release for a serious security issue that can result in
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojo/Server.pm
Expand Up @@ -2,6 +2,7 @@ package Mojo::Server;
use Mojo::Base 'Mojo::EventEmitter';

use Carp 'croak';
use Cwd 'abs_path';
use Mojo::Loader;
use Mojo::Util 'md5_sum';
use POSIX;
Expand Down Expand Up @@ -43,7 +44,7 @@ sub load_app {

# Clean environment (reset FindBin defensively)
{
local $0 = $path;
local $0 = $path = abs_path $path;
require FindBin;
FindBin->again;
local $ENV{MOJO_APP_LOADER} = 1;
Expand Down
2 changes: 2 additions & 0 deletions lib/Mojolicious.pm
Expand Up @@ -981,6 +981,8 @@ Tatsuhiko Miyagawa
Terrence Brannon
Tianon Gravi
Tomas Znamenacek
Ulrich Habel
Expand Down
6 changes: 6 additions & 0 deletions t/mojo/daemon.t
Expand Up @@ -6,6 +6,7 @@ BEGIN {
}

use Test::More;
use Cwd 'abs_path';
use File::Spec::Functions 'catdir';
use FindBin;
use Mojo;
Expand Down Expand Up @@ -62,6 +63,11 @@ is $app->config({test => 23})->config->{test}, 23, 'right value';
is_deeply $app->config, {foo => 'bar', baz => 'yada', test => 23},
'right value';

# Script name
my $path = "$FindBin::Bin/lib/../lib/myapp.pl";
is(Mojo::Server::Daemon->new->load_app($path)->config('script'),
abs_path($path), 'right script name');

# Load broken app
eval {
Mojo::Server::Daemon->new->load_app(
Expand Down
5 changes: 5 additions & 0 deletions t/mojo/lib/myapp.pl
@@ -0,0 +1,5 @@
use Mojolicious::Lite;

app->config(script => $0);

app->start;

0 comments on commit 88017f3

Please sign in to comment.