* supervising an apache RewriteMap program?
@ 2007-05-09 22:29 Robin Bowes
2007-06-02 16:50 ` Charlie Brady
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Robin Bowes @ 2007-05-09 22:29 UTC (permalink / raw)
To: supervision
Hi,
I'm using perl script as an Apache RewriteMap program [1]
Basically, this is started when apache starts and communication is via
stdin and stdout. A simple program (the example from the link below) is:
#!/usr/bin/perl
$| = 1;
while (<STDIN>) {
# ...put here any transformations or lookups...
print $_;
}
I'm using a much more complex example that does DB lookups, etc.
The problem arises when the program exits or dies for some reason -
apache doesn't restart it.
I'm wondering, could I use supervise or runsv to make sure the rewrite
map program is restarted?
First issue - the rewritemap program can't take parameters, i.e. it has
to be specified as a single word. So, I guess I could use a script that
execs runsv, e.g.:
RewriteMap aypFilterMap prg:/usr/bin/rewritemap_wrapper.sh
rewritemap_wrapper.sh:
====================================================
#!/bin/bash
exec runsv /var/apache/rewritemap
====================================================
/var/apache/rewritemap/run:
====================================================
#!/bin/bash
exec /usr/bin/myrewritemap.pl
====================================================
Second issue - as I mentioned earlier, apache communicates with the
rewrite map program through its stdin and stdout. It writes to the
program's stdin and reads from its stdout.
In normal use, the connected processes are simply:
apache<->myrewritemap.pl
In the configuration above, it's more complex:
apache<->rewritemap_wrapper.sh<->runsv<->run<->myrewritemap.pl
Using the configuration above, would the apache process be connected to
the stdin and stdout of the myrewritemap.pl script?
What about if/when the myrewritemap.pl script exits and is restarted?
Thanks for any insight into this.
Cheers,
R.
[1] http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritemap
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: supervising an apache RewriteMap program?
2007-05-09 22:29 supervising an apache RewriteMap program? Robin Bowes
@ 2007-06-02 16:50 ` Charlie Brady
2007-06-02 19:06 ` Robin Bowes
2007-06-02 21:00 ` Scott Gifford
2 siblings, 0 replies; 4+ messages in thread
From: Charlie Brady @ 2007-06-02 16:50 UTC (permalink / raw)
To: Robin Bowes; +Cc: supervision
On Wed, 9 May 2007, Robin Bowes wrote:
> The problem arises when the program exits or dies for some reason - apache
> doesn't restart it.
Perhaps this is best addressed as a bug/misfeature in apache.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: supervising an apache RewriteMap program?
2007-05-09 22:29 supervising an apache RewriteMap program? Robin Bowes
2007-06-02 16:50 ` Charlie Brady
@ 2007-06-02 19:06 ` Robin Bowes
2007-06-02 21:00 ` Scott Gifford
2 siblings, 0 replies; 4+ messages in thread
From: Robin Bowes @ 2007-06-02 19:06 UTC (permalink / raw)
To: supervision
Charlie Brady wrote:
>
> On Wed, 9 May 2007, Robin Bowes wrote:
>
>> The problem arises when the program exits or dies for some reason -
>> apache doesn't restart it.
>
> Perhaps this is best addressed as a bug/misfeature in apache.
I can certainly raise a bug against apache for this. However, I'm trying
to use existing tools to come up with a robust solution.
Anyone got any thoughts on how best to achieve this?
R.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: supervising an apache RewriteMap program?
2007-05-09 22:29 supervising an apache RewriteMap program? Robin Bowes
2007-06-02 16:50 ` Charlie Brady
2007-06-02 19:06 ` Robin Bowes
@ 2007-06-02 21:00 ` Scott Gifford
2 siblings, 0 replies; 4+ messages in thread
From: Scott Gifford @ 2007-06-02 21:00 UTC (permalink / raw)
To: Robin Bowes; +Cc: supervision
Robin Bowes <robin-lists@robinbowes.com> writes:
> I'm using perl script as an Apache RewriteMap program [1]
[...]
> I'm wondering, could I use supervise or runsv to make sure the rewrite
> map program is restarted?
Perhaps, but the handy things supervise does (like redirect file
descriptors) would be more of a hindrance than a help here, so it
would probably be much easier to wrap your script in another Perl
script that did something like:
while(1) {
system("/path/to/real/program");
}
That's still not perfect; a better solution would patch Apache to
restart the program (as Charlie suggests), or else to send requests
over a socket, which could be listened to by a supervised daemon.
Good luck!
----Scott.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-06-02 21:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-09 22:29 supervising an apache RewriteMap program? Robin Bowes
2007-06-02 16:50 ` Charlie Brady
2007-06-02 19:06 ` Robin Bowes
2007-06-02 21:00 ` Scott Gifford
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).