CC: | EJS [...] cpan.org |
When using Mojo::Server::FCGI::Prefork, there is no possibility to set
application class using $ENV{MOJO_APP} environment variable or
$server->app_class() accessor.
The problem brakes in two parts:
1) There is no way to access Mojo::Server::FCGI app_class attribute,
because when you set it for
Mojo::Server::FCGI::Prefork->app_class you set for next hierarchy:
Mojo::Server::Daemon::Prefork -> Mojo::Server::Daemon -> Mojo::Server.
Mojo::Server::FCGI which is instantiated in parent() routine doesn't get
this value.
2) Anyhow, one may say setting it via environment should work, but it
doesn't.
The problem with attributes is that it's default value isn't calculated
until the moment you really need to get it's value.
In Mojo::Server, app_class default value is defined as follows:
default => sub { $ENV{MOJO_APP} ||= 'Mojo::HelloWorld' }.
This whole setup led to following issue:
if you try to access app_class somewhere in parent() routine it gets
it's value from $ENV{MOJO_APP} since %ENV is still available and
Mojolicious or other application is working
if not - it is initialized somewhere in child()/process() routine where
%ENV is completely rewritten with FastCGI headers so it gets
Mojo::HelloWorld value, not very useful.