I just shipped Starman 0.2000 to CPAN. This release contains bug fixes from Graham Barr and Patrick Donelan on rare 100% cpu spin loops and a bug in Keep-alive handling on HTTP/1.0, but also has a major incompatible feature: preloading apps.
Preloading applications
plackup and all of its handlers, by default loads your application before running it on the server. So if you say:
plackup -s Starlet myapp.psgi
the myapp.psgi file is compiled in the master (parent) process and then the Starlet server preforks off children to run the compiled application. This saves a lot of memory in copy-on-write friendly environment, but might cause problems, if you want to initialize resources in the myapp.psgi compilation time, such as opening sockets or doing database connections.
Delayed loader
To solve this problem and make Starman's default safer, I introduced a new loader for Plack: Delayed. This is close to the Shotgun loader but it delays the compilation of the application until the first request time. It also passes the callback web servers can call to initialize the application earlier than the runtime, which Starman 0.2000's starman exeuctable now makes use of by default.
All plackup handlers still use the default loader by default, so if you want to use this loader with Starlet, you should say:
plackup -L Delayed -s Starlet myapp.psgi
but Starman's starman command automatically adds -L Delayed by default, so you don't need to. To continue preloading the app in the master to save memory (and you're sure that loading your app doesn't cause any shared resource issues), you can say:
starman --preload-app myapp.psgi
to keep the behavior pre 0.2000. Alternatively you can also say:
starman -MCatalyst -MDBIx::Class myapp.psgi
to load modules in the master, but delays the compilation of application until the per-children init hook.
BTW with this change the default behavior of Starman becomes the same with Rack's Unicorn. Read more about this in starman -h.
Recent Comments