Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Deploying a PSGI app in Apache without restarting (again)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mikolaj Kucharski  
View profile  
 More options Oct 29 2011, 8:25 am
From: Mikolaj Kucharski <miko...@kucharski.name>
Date: Sat, 29 Oct 2011 13:25:49 +0100
Local: Sat, Oct 29 2011 8:25 am
Subject: Deploying a PSGI app in Apache without restarting (again)
Hi,

I know this question was asked before here:

http://stackoverflow.com/questions/6124010/how-do-you-deploy-a-psgi-s...

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?

--
best regards
q#


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tatsuhiko Miyagawa  
View profile  
 More options Oct 29 2011, 3:16 pm
From: Tatsuhiko Miyagawa <miyag...@gmail.com>
Date: Sat, 29 Oct 2011 12:16:49 -0700
Local: Sat, Oct 29 2011 3:16 pm
Subject: Re: Deploying a PSGI app in Apache without restarting (again)
On Sat, Oct 29, 2011 at 5:25 AM, Mikolaj Kucharski

<miko...@kucharski.name> wrote:
> Hi,

> I know this question was asked before here:

> http://stackoverflow.com/questions/6124010/how-do-you-deploy-a-psgi-s...

> but I would like to understand where exactly is the output cached?

Output is not cached. The *application* is compiled and cached, for performance.

> I read Plack::Handler::Apache1 and Plack::Util, but I don't see any
> caching mechanism there, maybe I'm missing something.

https://metacpan.org/source/MIYAGAWA/Plack-0.9984/lib/Plack/Handler/A...
There's "||=" operator, caching the application.

> - 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.

--
Tatsuhiko Miyagawa


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mikolaj Kucharski  
View profile  
 More options Oct 29 2011, 4:43 pm
From: Mikolaj Kucharski <miko...@kucharski.name>
Date: Sat, 29 Oct 2011 21:43:00 +0100
Subject: Re: Deploying a PSGI app in Apache without restarting (again)

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..

--
best regards
q#


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tatsuhiko Miyagawa  
View profile  
 More options Oct 29 2011, 8:21 pm
From: Tatsuhiko Miyagawa <miyag...@gmail.com>
Date: Sat, 29 Oct 2011 17:21:10 -0700
Local: Sat, Oct 29 2011 8:21 pm
Subject: Re: Deploying a PSGI app in Apache without restarting (again)

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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mikolaj Kucharski  
View profile  
 More options Oct 30 2011, 2:08 pm
From: Mikolaj Kucharski <miko...@kucharski.name>
Date: Sun, 30 Oct 2011 18:08:49 +0000
Local: Sun, Oct 30 2011 2:08 pm
Subject: Re: Deploying a PSGI app in Apache without restarting (again)

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:

        http://search.cpan.org/dist/Plack/lib/Plack/Handler/CGI.pm

        http://search.cpan.org/dist/Plack/lib/Plack/Loader/Shotgun.pm

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.

References
 1. http://www4.kucharski.name/test/script-alias/list.cgi
 2. http://groups.google.com/group/mojolicious/browse_thread/thread/712fc...

--
best regards
q#


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jakob Voss  
View profile  
 More options Oct 30 2011, 7:10 pm
From: "Jakob Voss" <Jakob.V...@gbv.de>
Date: Mon, 31 Oct 2011 00:10:56 +0100
Local: Sun, Oct 30 2011 7:10 pm
Subject: Re: Deploying a PSGI app in Apache without restarting (again)

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.

I asked the original question on Stackoverflow some time ago. Your
presentation

http://www.slideshare.net/miyagawa/deploying-plack-web-applications-o...

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tatsuhiko Miyagawa  
View profile  
 More options Oct 30 2011, 7:13 pm
From: Tatsuhiko Miyagawa <miyag...@gmail.com>
Date: Sun, 30 Oct 2011 16:13:51 -0700
Local: Sun, Oct 30 2011 7:13 pm
Subject: Re: Deploying a PSGI app in Apache without restarting (again)

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.

--
Tatsuhiko Miyagawa


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mikolaj Kucharski  
View profile  
 More options Oct 31 2011, 12:57 pm
From: Mikolaj Kucharski <miko...@kucharski.name>
Date: Mon, 31 Oct 2011 16:57:41 +0000
Local: Mon, Oct 31 2011 12:57 pm
Subject: Re: Deploying a PSGI app in Apache without restarting (again)
Do you guys know why when putting full path to plackup in shebang
line doesn't work, but when using '/usr/bin/evn plackup' it does work?

        http://www4.kucharski.name/test/script-alias/list.cgi

--
best regards
q#

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tatsuhiko Miyagawa  
View profile  
 More options Oct 31 2011, 1:01 pm
From: Tatsuhiko Miyagawa <miyag...@gmail.com>
Date: Mon, 31 Oct 2011 10:01:07 -0700
Local: Mon, Oct 31 2011 1:01 pm
Subject: Re: Deploying a PSGI app in Apache without restarting (again)
Define "doesn't work". See the apache error log and find what is causing errors.

Sent from my iPad

On Oct 31, 2011, at 9:57 AM, Mikolaj Kucharski <miko...@kucharski.name> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mikolaj Kucharski  
View profile  
 More options Oct 31 2011, 1:41 pm
From: Mikolaj Kucharski <miko...@kucharski.name>
Date: Mon, 31 Oct 2011 17:41:09 +0000
Local: Mon, Oct 31 2011 1:41 pm
Subject: Re: Deploying a PSGI app in Apache without restarting (again)
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..

--
best regards
q#

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mikolaj Kucharski  
View profile  
 More options Oct 31 2011, 8:25 pm
From: Mikolaj Kucharski <miko...@kucharski.name>
Date: Tue, 1 Nov 2011 00:25:29 +0000
Local: Mon, Oct 31 2011 8:25 pm
Subject: Re: Deploying a PSGI app in Apache without restarting (again)

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.

--
best regards
q#


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »