Re: how to catch a killed task?

2001-10-10 Thread Stas Bekman

Christoph Bergmann wrote:

 Stas Bekman wrote:
 
Christoph Bergmann wrote:


hi...

i use BSD::Resource to limit the ressources of the apache tasks. this
works fine but now i want to clean up afterwards but i don't know how to
catch a killed task... here is what i tried with signals:

...


Does the following help? (Look at the register_cleanup method)

http://thingy.kcilink.com/modperlguide/debug/Safe_Resource_Locking_and_Cleanu.html


 
 thanks, this works. while playing around with it I found $SIG{__DIE__}
 in your mod_perl guide which fits even better to my needs (I have read
 about the problems as well but I think its ok for me) because the
 connection is still open and I can print out information about what has
 happened.
 
 one more question: after processing the sub given to $SIG{__DIE__}
 apache prints out an internal server error - how can I avoid/suppress
 this?

I've no idea in what setup you are calling this. If it's a registry 
script you just exit. If it's a handler, you should return OK.

But you read 
http://perl.apache.org/guide/perl.html#Exception_Handling_for_mod_perl
aren't you?


_
Stas Bekman JAm_pH  --   Just Another mod_perl Hacker
http://stason.org/  mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/




Re: how to catch a killed task?

2001-10-09 Thread Christoph Bergmann

Perrin Harkins wrote:
 
 I believe the limiting done by BSD::Resource is pretty harsh and may
 actually be at the kernel level.  I don't think you can catch the signal and
 deal with it yourself.  What you should do is use Apache::SizeLimit to
 handle your size constraints, and just use BSD::Resource for extreme cases,
 i.e. out of control servers in tight loops.
 

Thanks for your answer, but (I think) I need BSD::Resource because I
allow users to write their own scripts (executed with reval from the
Safe-Module) and they can write infinite loops or consume memory as they
want - Apache::SizeLimit is not harsh enough for this ;-)

Best regards,

Christoph Bergmann



Re: how to catch a killed task?

2001-10-09 Thread Perrin Harkins

 Perrin Harkins wrote:
 
  I believe the limiting done by BSD::Resource is pretty harsh and may
  actually be at the kernel level.  I don't think you can catch the signal
and
  deal with it yourself.  What you should do is use Apache::SizeLimit to
  handle your size constraints, and just use BSD::Resource for extreme
cases,
  i.e. out of control servers in tight loops.
 

 Thanks for your answer, but (I think) I need BSD::Resource because I
 allow users to write their own scripts (executed with reval from the
 Safe-Module) and they can write infinite loops or consume memory as they
 want - Apache::SizeLimit is not harsh enough for this ;-)

Correct, which is why I said to use both.  SizeLimit catches normal growth,
and BSD::Resource catches emergencies.  You set the limit for BSD::Resource
higher than the one for SizeLimit.
- Perrin




Re: how to catch a killed task?

2001-10-09 Thread Christoph Bergmann

Stas Bekman wrote:
 
 Christoph Bergmann wrote:
 
  hi...
 
  i use BSD::Resource to limit the ressources of the apache tasks. this
  works fine but now i want to clean up afterwards but i don't know how to
  catch a killed task... here is what i tried with signals:
 
  ...
 
 
 Does the following help? (Look at the register_cleanup method)
 
 http://thingy.kcilink.com/modperlguide/debug/Safe_Resource_Locking_and_Cleanu.html
 

thanks, this works. while playing around with it I found $SIG{__DIE__}
in your mod_perl guide which fits even better to my needs (I have read
about the problems as well but I think its ok for me) because the
connection is still open and I can print out information about what has
happened.

one more question: after processing the sub given to $SIG{__DIE__}
apache prints out an internal server error - how can I avoid/suppress
this?


best regards,

christoph bergmann



Re: how to catch a killed task?

2001-10-09 Thread Christoph Bergmann

Perrin Harkins wrote:
 
  Perrin Harkins wrote:
  
   I believe the limiting done by BSD::Resource is pretty harsh and may
   actually be at the kernel level.  I don't think you can catch the signal
 and
   deal with it yourself.  What you should do is use Apache::SizeLimit to
   handle your size constraints, and just use BSD::Resource for extreme
 cases,
   i.e. out of control servers in tight loops.
  
 
  Thanks for your answer, but (I think) I need BSD::Resource because I
  allow users to write their own scripts (executed with reval from the
  Safe-Module) and they can write infinite loops or consume memory as they
  want - Apache::SizeLimit is not harsh enough for this ;-)
 
 Correct, which is why I said to use both.  SizeLimit catches normal growth,
 and BSD::Resource catches emergencies.  You set the limit for BSD::Resource
 higher than the one for SizeLimit.
 - Perrin

Oops, sorry, I overlooked that. Yes that makes sense...

Best regards,

Christoph Bergmann



Re: how to catch a killed task?

2001-10-07 Thread Stas Bekman

Christoph Bergmann wrote:

 hi...
 
 i use BSD::Resource to limit the ressources of the apache tasks. this
 works fine but now i want to clean up afterwards but i don't know how to
 catch a killed task... here is what i tried with signals:
 
 my entries in httpd.conf:
 
 PerlModule Apache::Resource
 PerlSetEnv PERL_RLIMIT_CPU 120:150
 PerlSetEnv PERL_RLIMIT_AS 3000:3500
 PerlChildInitHandler Apache::Resource
 
 and this is how i tried to catch the signals:
 
 sub cleanup { die cleanup called...; }
 $SIG{XFSZ} = \cleanup;
 
 i use linux, thus i have to use RLIMIT_AS and so maybe XFSZ is the wrong
 signal for the RAM limit. which do i have to use then?
 
 but i tried $SIG{XCPU} but it doesnt work as well.
 
 it just killed the task at soft limit without calling cleanup. what is
 wrong?
 
 or is there another possibility for cleaning up? probably there is a
 handler i can use which will be called when a program is finished, if
 so, how can i check if the program has ended as it shoulds or if it was
 killed by BSD::resource ?
 
 thanx in advance!
 
 best regards,
 
 christoph bergmann
 



Does the following help? (Look at the register_cleanup method)


http://thingy.kcilink.com/modperlguide/debug/Safe_Resource_Locking_and_Cleanu.html

-- 


_
Stas Bekman JAm_pH  --   Just Another mod_perl Hacker
http://stason.org/  mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/




Re: how to catch a killed task?

2001-10-07 Thread Perrin Harkins

 it just killed the task at soft limit without calling cleanup. what is
 wrong?

I believe the limiting done by BSD::Resource is pretty harsh and may
actually be at the kernel level.  I don't think you can catch the signal and
deal with it yourself.  What you should do is use Apache::SizeLimit to
handle your size constraints, and just use BSD::Resource for extreme cases,
i.e. out of control servers in tight loops.

 or is there another possibility for cleaning up? probably there is a
 handler i can use which will be called when a program is finished, if
 so, how can i check if the program has ended as it shoulds or if it was
 killed by BSD::resource ?

Put your cleanup code in a PerlChildExitHandler.  Apache::SizeLimit will
allow this to be called, since it uses the $r-child_terminate() call.
BSD::Resource just does a harsh kill.

- Perrin




how to catch a killed task?

2001-10-06 Thread Christoph Bergmann

hi...

i use BSD::Resource to limit the ressources of the apache tasks. this
works fine but now i want to clean up afterwards but i don't know how to
catch a killed task... here is what i tried with signals:

my entries in httpd.conf:

PerlModule Apache::Resource
PerlSetEnv PERL_RLIMIT_CPU 120:150
PerlSetEnv PERL_RLIMIT_AS 3000:3500
PerlChildInitHandler Apache::Resource

and this is how i tried to catch the signals:

sub cleanup { die cleanup called...; }
$SIG{XFSZ} = \cleanup;

i use linux, thus i have to use RLIMIT_AS and so maybe XFSZ is the wrong
signal for the RAM limit. which do i have to use then?

but i tried $SIG{XCPU} but it doesnt work as well.

it just killed the task at soft limit without calling cleanup. what is
wrong?

or is there another possibility for cleaning up? probably there is a
handler i can use which will be called when a program is finished, if
so, how can i check if the program has ended as it shoulds or if it was
killed by BSD::resource ?

thanx in advance!

best regards,

christoph bergmann