I generally recommend shell-based tools to manage process demonization, whether using
forks.pm or not. These avoid any possible side effects or compatibility issues.
Some ideas:
- supervise (part of the daemontools package):
http://cr.yp.to/daemontools.html
- panctl:
http://search.cpan.org/search?query=panctl&mode=all
- Roll your own shell script
If writing your own script, I recommend reviewing the 'apachectl' script included with the
Apache httpd distribution. This is a nice example of a complete shell daemon script manager,
SysV command style.
For managed log rotation, consider some the following:
- multilog (
http://cr.yp.to/daemontools/multilog.html): Runs in-line with your script, or
piped output via Perl open(). No signal handling necessary.
- logrotate: Runs externally from your script. You must handle a custom HUP signal. Can
handle any log file
- Log4Perl with RollingFileAppender or SysLogAppender: Can handle any log file. Most
configurable Perl solution
Personally, I always write my own daemon-control scripts, frequently in combination with
multilog.
On the original bug topic, I had evaluated fork()/exit from forks.pm main thread and not
terminating the thread group. I was dissatisfied with internal side effects with the supervisor
thread (e.g. it becomes an orphan process, with respect to the script). So I'd rather not add
this feature to the forks.pm core, as I feel it would cause more instability and cleanup issues
than simply using a wrapper daemon script or utility.
On Wed Nov 10 10:39:04 2010, faxm0dem wrote:
Show quoted text> Hi,
>
> Le Mar 07 Avr 2009 02:56:21, RYBSKEJ a écrit :
> > So, it may be feasible to add a new feature in forks.pm to allow
> > demonization of a threaded
> > app: termination of main thread without exiting process group. I'd
> > imagine it would logically reassign main thread ownership to the child
> > fork() process (auto-casting the forked process
> > as a thread->isthread), such that ithread semantics remain consistent.
> > But this would still
> > not behave the same as threads.pm for reasons noted earlier, so I
> > wonder if an alternate
> > solution would better suit your design needs?
>
> I'm still struggling with this issue.
> What would be the best way to implement a daemon using forks.pm ?