On Sat, 27 Feb 2010 12:40:17 -0600
Harry Putnam <rea...@newsguy.com> wrote:

> > reload() {
> >         ebegin "Reloading evolone_agi configuration" 
> >     start-stop-daemon --signal 1
> > --pidfile /var/run/evolone_agi.pid eend $? "Error reloading
> > evolone_agi" }  

> Thanks ... good info.  How does the script behave regarding what
> happens if it receives a sigINT or sigKILL, or some other way dies
> (even from an internal error)?

This script is more proof-of-concept piece hacked together in an hour
which just routes my outgoing calls to local free PSTN or SIP. So I know
if it needs restarting when I can't make a call from home. ;-)

Basically, I think if you perldoc Net::Server[::SIG]

In there is:

  $self->pre_server_close_hook;

... might be your friend to share some Sys::Syslog routines.

In the Net::Server code:
### set some sigs
  $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = sub { $self->server_close; };

  ### most cases, a closed pipe will take care of itself
  $SIG{PIPE} = 'IGNORE';

  ### catch children (mainly for Fork and PreFork but works for any
  chld) $SIG{CHLD} = \&sig_chld;

  ### catch sighup
  $SIG{HUP} = sub { $self->sig_hup; }


... seems to have it covered for most cases. ;-) You can see sig_hup is
almost expected to do something.

> 
> Does it log to syslog? and notify sysadmin?

I think a good use of Net::Server::* and Sys::Syslog can get you where
you want. I'd bet you can put anything in that pre_server_close_hook
hook... send an email, set off the building alarms... it's perl, after
all. But I really haven't done much directly with it.

> 
> I haven't had occasion to run into an `EXIT trap' in perl... but there
> must be such a thing.
> 

perldoc -q signal
perldoc perlipc

HTH.

-- 
 |\  /|        |   |          ~ ~  
 | \/ |        |---|          `|` ?
 |    |ichael  |   |iggins    \^ /
 michael.higgins[at]evolone[dot]org

Reply via email to