in reply to Re: Generic Daemon Use
in thread Generic Daemon Use

Thanks for the reply. I do have the conf file in /etc. I'm getting no error output when using $!.

Replies are listed 'Best First'.
Re^3: Generic Daemon Use
by andyford (Curate) on Feb 02, 2007 at 18:20 UTC

    Here's another thought: run your Daemon in the foreground:

    newdaemon( progname => 'ticktockd', pidfile => '/var/run/ticktockd.pid', configfile => '/etc/ticktockd.conf', foreground => 1, );
    If it's running in the background you may never see any output.

    non-Perl: Andy Ford

      Thanks again. Foregrounding it I see that the Generic.pm module is calling a subroutine named write_file (for writing the pid file) that doesn't exist. I'm not sure where that particular subroutine is supposed to be found but I wrote added one of my own to that module file and got the daemon to run and stay running. I'll play around some more with it. I just needed to get past this hurdle. Thanks for your help!

        write_file is exported by File::Slurp, which the module uses at the top of the file. It looks like the return value from it isn't checked though, so if the problem is that it is failing to write the pidfile for some reason that would explain why your replacement of it with your own subroutine seems to help.

        -- David Irving

        Wow, you're right, that routine never got implemented, just documented. Hee. I'd report it as a bug

        non-Perl: Andy Ford

Re^3: Generic Daemon Use
by andyford (Curate) on Feb 02, 2007 at 18:14 UTC

    Well then, I'd say it's probably time to start sprinkling print statements into your code. For instance you might do (untested)

    sub gd_preconfig { my ($self) = @_; print "opening config file\n"; open(CONFIG, "</etc/ticktockd.conf") or die "Failure opening c +onfig file:$!"; while(<CONFIG>) { $sleeptime = $1 if /^sleeptime\s+(\d+)/; } close(CONFIG); print "done reading config, sleeptime is now $sleeptime\n"; return (); }
    Oh, and I just noticed that you need to add "use strict" to the top of your program! Very important!

    non-Perl: Andy Ford