in reply to Re: Win32::Daemon problem
in thread Win32::Daemon problem

You're right, thanks for the spot but that's not what was causing the problem.

After some research, I found that the real problem was that the perl interpreter wasn't able to find the package I was trying to include because the service gets started from a different directory than the one where I placed my script and module.

This problem is now solved by adding the directory to the @INC list :

use lib "c:/mypath";

Regards,

<ruelty

Replies are listed 'Best First'.
Re: Re: Re: Win32::Daemon problem
by $code or die (Deacon) on Sep 21, 2001 at 03:44 UTC
    Ahh. I've run into similar problems before. Win32 services are more difficult to debug because you can't see what's going on. What I've done in the past is log errors to a text file. This is fine for development, but in production you probably want to use the Event Log, with Win32::EventLog or Win32::EventLog::Message - I don't have a link, but I think it's another one of Dave Roth's.

    I find something along these lines useful:
    BEGIN { $SIG{__WARN__} = $SIG{__DIE__} = sub { open ERRORLOG, ">>/myerror.log" or die "error opening logfile"; print ERRORLOG, scalar localtime, " - $0\n", @_, "\n\n"; close ERRORLOG; } }
    I think this would have caught your problem and written it to a log file.

    John M. Dlugosz pointed out recently that you can also use Win32::MessageBox from within a Service. So you could replace that logfile with a more immediate and visual prompt.

    Simon Flack ($code or die)
    $,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
    =~y'_"' ';eval"die";print $_,lc substr$@,0,3;