Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Generic Daemon Use

by andyford (Curate)
on Feb 02, 2007 at 16:34 UTC ( [id://597960]=note: print w/replies, xml ) Need Help??


in reply to Generic Daemon Use

Do you have a "/etc/ticktockd.conf"? Could it be die-ing trying to read a non-existant file? Maybe change

open(CONFIG, "</etc/ticktockd.conf") or die;
to
open(CONFIG, "</etc/ticktockd.conf") or die "Failure opening config fi +le: $!"

non-Perl: Andy Ford

Replies are listed 'Best First'.
Re^2: Generic Daemon Use
by smist (Acolyte) on Feb 02, 2007 at 18:05 UTC
    Thanks for the reply. I do have the conf file in /etc. I'm getting no error output when using $!.

      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!

      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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://597960]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-18 05:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found