jaandy has asked for the wisdom of the Perl Monks concerning the following question:
I have a new daemon (using Proc::Daemon) that I'd like to sighup to get it to reload config, but no matter what I do, it kills the daemon.
After:
Proc::Daemon::Init();
I use:
I get the message in the log, but then my daemon dies. I've tried changing the code inside to something simpler, but it doesn't seem to matter. On the other hand $SIG{HUP} = 'IGNORE' works fine.$SIG{HUP} = sub { if (defined $log) { undef $log; } $log = IO::File->new(LOGFILE, 'w'); $log->print(strftime("%m/%d/%Y %H:%M:%S", localtime),": Caught HUP, +reset logfile\n"); $log->print("pid = $$\n"); $log->autoflush(1); };
If I create a simple script it doesn't kill the program when I sighup it:
#!/usr/bin/perl $SIG{HUP} = sub { print "got hup\n"; }; while (1) { print "sleeping\n"; sleep(1); }
The searching I have done show's lots of examples of restarting the script, but I cannot find any that just reaload configs (well, perl daemons that reaload).
Is there something different about how sighup works on regular apps vs daemon apps?
Thanks for your time,
-Andy
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: SIGHUP with Proc::Daemon
by Eliya (Vicar) on Mar 09, 2012 at 18:48 UTC | |
by jaandy (Acolyte) on Mar 09, 2012 at 19:06 UTC | |
by jaandy (Acolyte) on Mar 09, 2012 at 19:18 UTC | |
by Eliya (Vicar) on Mar 09, 2012 at 19:56 UTC | |
by Eliya (Vicar) on Mar 09, 2012 at 19:13 UTC |
Back to
Seekers of Perl Wisdom