but I would like to understand where exactly is the output cached? I read Plack::Handler::Apache1 and Plack::Util, but I don't see any caching mechanism there, maybe I'm missing something.
- Is it cached on Apache level, or in Plack/PSGI?
- Is the behaviour described at above StackOverflow link specific to Apache and would behave differently with other HTTP server?
> - Is it cached on Apache level, or in Plack/PSGI?
> - Is the behaviour described at above StackOverflow link specific to > Apache and would behave differently with other HTTP server?
Yes, but most Plack handlers and PSGI servers compile the PSGI code and runs it in a persistent environment. The only exceptions are CGI handler and Shotgun loader, which recompiles the application every time a request comes in.
On Sat, Oct 29, 2011 at 12:16:49PM -0700, Tatsuhiko Miyagawa wrote: > On Sat, Oct 29, 2011 at 5:25 AM, Mikolaj Kucharski > <miko...@kucharski.name> wrote: > > Hi,
> > - Is it cached on Apache level, or in Plack/PSGI?
> > - Is the behaviour described at above StackOverflow link specific to > > Apache and would behave differently with other HTTP server?
> Yes, but most Plack handlers and PSGI servers compile the PSGI code > and runs it in a persistent environment. The only exceptions are CGI > handler and Shotgun loader, which recompiles the application every > time a request comes in.
Thanks for the anwsers. Much appreciated.
I'm learning, I'm a noob. In the past working with CGI, I could throw bunch of testing scripts under a directory tree, modify them at any time and see what happens after refreshing a page in a browser, without any need to restart http server every time a change a character in a file.
So far no matter what I try to (re)create above scenario in PSGI environment I hit a bug (some call it a ``feature'') which doesn't allow me just work on the code and forget what server I'm running, and what PSGI is all about.
Can anyone recommend me a solution for my need? I thought PSGIBin will solve my problem, but so far it's not the case..
What you have is more about the issues with Mojolicious not allowing multi tenancy in one process like pointed out in the other thread.
For a development you can still use restarting handlers like CGI or Shotgun loader, but for a deployment you might have to use a non-lite mojolicious app that might not have that problem, or otherwise consult Mojolicious to fix that issue. On Oct 29, 2011 1:43 PM, "Mikolaj Kucharski" <miko...@kucharski.name> wrote:
> > > - Is it cached on Apache level, or in Plack/PSGI?
> > > - Is the behaviour described at above StackOverflow link specific to > > > Apache and would behave differently with other HTTP server?
> > Yes, but most Plack handlers and PSGI servers compile the PSGI code > > and runs it in a persistent environment. The only exceptions are CGI > > handler and Shotgun loader, which recompiles the application every > > time a request comes in.
> Thanks for the anwsers. Much appreciated.
> I'm learning, I'm a noob. In the past working with CGI, I could throw > bunch of testing scripts under a directory tree, modify them at any time > and see what happens after refreshing a page in a browser, without any > need to restart http server every time a change a character in a file.
> So far no matter what I try to (re)create above scenario in PSGI > environment I hit a bug (some call it a ``feature'') which doesn't allow > me just work on the code and forget what server I'm running, and what > PSGI is all about.
> Can anyone recommend me a solution for my need? I thought PSGIBin will > solve my problem, but so far it's not the case..
On Sat, Oct 29, 2011 at 05:21:10PM -0700, Tatsuhiko Miyagawa wrote: > For a development you can still use restarting handlers like CGI or Shotgun > loader, but for a deployment you might have to use a non-lite mojolicious > app that might not have that problem, or otherwise consult Mojolicious to > fix that issue.
Ok. Regards CGI handler and Shotgun loader. Do you mean this:
In documentation of CGI handler for Plack there is an example:
------------------------8<------------------------ Want to run PSGI application as a CGI script? Rename .psgi to .cgi and change the shebang line like:
#!/usr/bin/env plackup # rest of the file can be the same as other .psgi file ------------------------8<------------------------
Above it is working for me on Apache with mod_perl and Mojolicious::Lite now, however I think I've tried this in the past and it did not worked as I've put full path to plackup(1) on shebang line:
# head -n1 env-plackup-mojo.pl plackup-mojo.pl ==> env-plackup-mojo.pl <== #!/usr/bin/env plackup
==> plackup-mojo.pl <== #!/usr/local/bin/plackup
Surprisingly the second script doesn't work[#ref1]. Do you know maybe why?
Thanks again for above tips about CGI handler and Shotgun loader, I will definately check them out.
is very helpful, but some more-detailled best-practice guide wouldn't be wrong. In particular I found that the following setup is very handy
1. use plackup (with -r) during development 2. use directory layout and settings as documented by DotCloud 3. push to DotCloud for smoke testing 4. run a gracefully restartable webserver (Starman) in user space (high port) at production 5. don't forget to add a startup script to start Starman after reboot! 6. put a reverse proxy (Nginx, Apache...) in front (port 80) 7. host project in a git repository at production 8. add a git post-recieve hook at production to automatically restart Starman
This way I never have to login at production and manually restart a service. As HTML templates, CSS, images etc. are served static, you can still edit them on production in case of emergency, but the Perl code should never be edited on a live system. I suppose this lesson is new for instance to developes coming from PHP ;-)
Hope this helps someone else too.
Cheers Jakob
-- Verbundzentrale des GBV (VZG) Digitale Bibliothek - Jakob Vo Platz der Goettinger Sieben 1 37073 Goettingen - Germany +49 (0)551 39-10242 http://www.gbv.de jakob.v...@gbv.de
On Sun, Oct 30, 2011 at 4:10 PM, Jakob Voss <Jakob.V...@gbv.de> wrote: > is very helpful, but some more-detailled best-practice guide wouldn't be > wrong. In particular I found that the following setup is very handy
> 1. use plackup (with -r) during development > 2. use directory layout and settings as documented by DotCloud > 3. push to DotCloud for smoke testing > 4. run a gracefully restartable webserver (Starman) in user space (high > port) at production > 5. don't forget to add a startup script to start Starman after reboot! > 6. put a reverse proxy (Nginx, Apache...) in front (port 80) > 7. host project in a git repository at production > 8. add a git post-recieve hook at production to automatically restart > Starman
> This way I never have to login at production and manually restart a > service. As HTML templates, CSS, images etc. are served static, you can > still edit them on production in case of emergency, but the Perl code > should never be edited on a live system. I suppose this lesson is new > for instance to developes coming from PHP ;-)
> Hope this helps someone else too.
I'm sure all of these are automatically taken care of if you use PaaS like dotcloud.
Otherwise, well volunteered.
P.S. I'm giving a tutorial in London for this in about 2 weeks.
On Sun, Oct 30, 2011 at 06:08:49PM +0000, Mikolaj Kucharski wrote: > In documentation of CGI handler for Plack there is an example:
> ------------------------8<------------------------ > Want to run PSGI application as a CGI script? Rename .psgi to .cgi and > change the shebang line like:
> #!/usr/bin/env plackup > # rest of the file can be the same as other .psgi file > ------------------------8<------------------------
> Above it is working for me on Apache with mod_perl and > Mojolicious::Lite now, however I think I've tried this in the past and it > did not worked as I've put full path to plackup(1) on shebang line:
> On Sun, Oct 30, 2011 at 06:08:49PM +0000, Mikolaj Kucharski wrote: >> In documentation of CGI handler for Plack there is an example:
>> ------------------------8<------------------------ >> Want to run PSGI application as a CGI script? Rename .psgi to .cgi and >> change the shebang line like:
>> #!/usr/bin/env plackup >> # rest of the file can be the same as other .psgi file >> ------------------------8<------------------------
>> Above it is working for me on Apache with mod_perl and >> Mojolicious::Lite now, however I think I've tried this in the past and it >> did not worked as I've put full path to plackup(1) on shebang line:
Request returns HTTP 500 with following lines in error_log:
[Mon Oct 31 18:16:21 2011] [error] (8)Exec format error: exec of /var/www/test/plackup-mojo.pl failed [Mon Oct 31 18:16:21 2011] [error] [client 195.99.160.66] Premature end of script headers: /var/www/test/plackup-mojo.pl
and script is readable and executable by all, but it looks unrelated to Plack. I need to investigate this myself:
# /var/www/test/plackup-mojo.pl /var/www/test/plackup-mojo.pl[3]: use: not found /var/www/test/plackup-mojo.pl[5]: get: not found /var/www/test/plackup-mojo.pl[6]: get: not found /var/www/test/plackup-mojo.pl[8]: app-: not found /var/www/test/plackup-mojo.pl[10]: __DATA__: not found /var/www/test/plackup-mojo.pl[11]: @@: not found /var/www/test/plackup-mojo.pl[12]: syntax error: `< ' unexpected
# head -n1 /var/www/test/plackup-mojo.pl #!/usr/local/bin/plackup
# head -n1 /usr/local/bin/plackup #!/usr/bin/perl
No joy with shebang line to a script? Anyway I'll try to figure it out..
> > On Sun, Oct 30, 2011 at 06:08:49PM +0000, Mikolaj Kucharski wrote: > >> In documentation of CGI handler for Plack there is an example:
> >> ------------------------8<------------------------ > >> Want to run PSGI application as a CGI script? Rename .psgi to .cgi and > >> change the shebang line like:
> >> #!/usr/bin/env plackup > >> # rest of the file can be the same as other .psgi file > >> ------------------------8<------------------------
> >> Above it is working for me on Apache with mod_perl and > >> Mojolicious::Lite now, however I think I've tried this in the past and it > >> did not worked as I've put full path to plackup(1) on shebang line:
On Mon, Oct 31, 2011 at 05:41:09PM +0000, Mikolaj Kucharski wrote: > Request returns HTTP 500 with following lines in error_log:
> [Mon Oct 31 18:16:21 2011] [error] (8)Exec format error: exec of /var/www/test/plackup-mojo.pl failed > [Mon Oct 31 18:16:21 2011] [error] [client 195.99.160.66] Premature end of script headers: /var/www/test/plackup-mojo.pl
> and script is readable and executable by all, but it looks unrelated to > Plack. I need to investigate this myself:
> # /var/www/test/plackup-mojo.pl > /var/www/test/plackup-mojo.pl[3]: use: not found > /var/www/test/plackup-mojo.pl[5]: get: not found > /var/www/test/plackup-mojo.pl[6]: get: not found > /var/www/test/plackup-mojo.pl[8]: app-: not found > /var/www/test/plackup-mojo.pl[10]: __DATA__: not found > /var/www/test/plackup-mojo.pl[11]: @@: not found > /var/www/test/plackup-mojo.pl[12]: syntax error: `< ' unexpected
> # head -n1 /var/www/test/plackup-mojo.pl > #!/usr/local/bin/plackup
> # head -n1 /usr/local/bin/plackup > #!/usr/bin/perl
> No joy with shebang line to a script? Anyway I'll try to figure it out..
FYI: This is not Plack issue, and is specific to OpenBSD. I've created small testing scripts and compared their execution with Linux. On OpenBSD you can see error (see above, see below) under Linux it works.
ktrace says: execve -1 errno 8 Exec format error
Just so you know if someone else runs into the same issue like me.