Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Can Win32::Daemon access remote shares?

by Jenda (Abbot)
on Apr 13, 2003 at 18:43 UTC ( [id://250156]=note: print w/replies, xml ) Need Help??


in reply to Can Win32::Daemon access remote shares?

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

Replies are listed 'Best First'.
Re: Re: Can Win32::Daemon access remote shares?
by rah (Monk) on Apr 13, 2003 at 18:58 UTC
    That looks great Jenda. Though I don't know if it is what everyone else would want. I would love for the die to really die, i.e. stop the service. I think ot would be much safer that way. No risk of a runaway service.

    For now, I think if I could just get the install to work as a network capable user, I would be home free. But setting the params in the info section always fails with :

    Failed to install: The account name is invalid or does not exist.
    If you or anyone could suggest a way around that, I'd appreciate it. Even if you just send me off in search of some other resources. :>

      That's why it would be optional. The reason why I do not want the die to really die is that IMHO most often the reason of the die is something temporary. Something I forgot the check for and that will eventualy work again. Like for example that the remote computer/database is temporarily inaccessible, because it's being rebooted or something similar. Therefore I only want to write the error into the log file and try to continue.

      Since I have scripts that process the log files each night, archive them and report any errors or unexpected messages, I do notice there was something uncaught at worst the next morning.

      To get back to your problem, did you specify the domain of the user? Or if the account is local then you should use either "computername\user" or ".\user". I think the only computer where you would not have to specify the domain would be a domain controler (Erm ... I don't know how Active Directory works in regard to this. I'm talking about the good old NT domain controlers.)

      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

        Well. that fixed the install problem. Thank you. FWIW this is the PDC under gool ole NT. The .\user got the install to work, but starting the service now gives the following:
        System error 1069 has occurred. The service did not start due to a logon failure.
        I'm hoping this isn't something else simple that I've just missed. Is there anything special about how the password is entered?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-12-03 08:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found