diff --git a/lib/Starman/Server.pm b/lib/Starman/Server.pm index e03f2e7..4dac4b8 100644 --- a/lib/Starman/Server.pm +++ b/lib/Starman/Server.pm @@ -171,7 +171,17 @@ sub child_init_hook { srand(); if ($self->{options}->{psgi_app_builder}) { DEBUG && warn "[$$] Initializing the PSGI app\n"; - $self->{app} = $self->{options}->{psgi_app_builder}->(); + eval { + $self->{app} = $self->{options}->{psgi_app_builder}->(); + 1; + } or do { + if ($@ =~ /Error while loading/) { + DEBUG && warn "[$$] Failed to load the app, will try again on request: $@\n"; + } + else { + die $@; + } + } } $0 = "starman worker " . join(" ", @{$self->{options}{argv} || []}) if $self->{options}{proctitle};