As buk said, the problem is most likely in the premissions. If your service runs under the LocalSystem account it doesn't have acccess the WINDOWS networking. You have to run the service under some different account.
On "the re-execing": Win32::Daemon::Simple tries its best to prevent the service from crashing. It will write the error into the log file and try to continue. If you want to make more noise at this time you can either
- use your own custom Die() procedure that'll send a network message or an email and then stop the service
- wrap your code in an eval block, catch the exceptions, send the alert and stop the service.
Just a note. You should call
Win32::Daemon::StopService(); before you exit().
If you think it would be helpfull I can update Win32::Daemon::Simple to send a network message ("net send ...") to somewhere if your callback dies and optionaly to even stop the service. I'd say ... if the Params=> option of use Win32::Daemon::Simple contains MessageOnError=> it would send the network alert to the specified username/computer. And then another option StopOnError would control whether to "re-exec" or stop. Something like this:
use Win32::Daemon::Simple
Service => 'SERVICENAME',
Name => 'SERVICE NAME',
Version => 'x.x',
StopOnError => 1,
Info => {
...
},
Params => {
MsgOnError => Win32::NodeName(), # send to local console
Tick => 0,
Talkative => 0,
...
};
Does that look OK? If anyone has some other suggestions, send them to me. I might even implement them ;-)
Jenda
Always code as if the guy who ends up maintaining your code
will be a violent psychopath who knows where you live.
-- Rick Osborne
Edit by castaway: Closed small tag in signature |