Преглед на файлове

rebase: apply review feedback on #4

Kōan преди 4 месеца
родител
ревизия
f2d6a75405
променени са 1 файла, в които са добавени 6 реда и са изтрити 17 реда
  1. 6 17
      bin/tpsgi

+ 6 - 17
bin/tpsgi

@@ -54,23 +54,12 @@ our $app = sub {
     # Change your dir into whatever basedir you need to be in
     chdir("$options{tpsgi_dir}/$options{basedir}") or die "Can't chdir into $options{tpsgi_dir}/$options{'basedir'}: $!";
 
-    # Profiler is opt-in: set NYTPROF env var to enable.
-    # The default path is used when NYTPROF is set without a file= clause.
-    if ($ENV{NYTPROF}) {
-        $ENV{NYTPROF} = "sigexit=1:savesrc=0:start=no:file=$options{tpsgi_dir}/prof/nytprof.out"
-            unless $ENV{NYTPROF} =~ /file=/;
-        require Devel::NYTProf;
-        mkdir "$options{tpsgi_dir}/prof";
-    }
+    # If we have manually set the NYTPROF var, use it and don't try to control
+    # When to stop or start it.
+    $ENV{NYTPROF} ||= "sigexit=1:savesrc=0:start=no:file=$options{tpsgi_dir}/prof/nytprof.out";
+    require Devel::NYTProf;
+    mkdir "$options{tpsgi_dir}/prof";
 
     my $self = TPSGI->new(%options);
-
-    # TPSGI::app already catches all _app exceptions internally.
-    # This outer eval is a last-resort safety net only.
-    my $result = eval { $self->app(@_) };
-    return $result if defined $result;
-
-    my $env = $_[0];
-    $env->{'psgi.errors'}->print($@) if $env && ref $env eq 'HASH' && $env->{'psgi.errors'};
-    return [500, ['Content-Type', 'text/plain', 'Content-Length', 21], ['Internal Server Error']];
+    return $self->app(@_);
 };