http://qs1969.pair.com?node_id=11100651


in reply to Win32::Daemon service doesn't reach RUNNING state

I don't have a setup where I can easily try to reproduce your results, however, I notice that you don't do much with the return value of CreateService(). Per the module docs, you should be calling GetLastError() when CreateService() returns false. The underlying service docs go into a bit more detail about the data that might be returned. (You'll likely need to dig up the underlying constant values.)

I'd start by trying to get more extended error info. That should lead you to the next step in your investigation.

(One obvious question is "Are you running this as an admin?" The note on the CPAN doc (see link above) suggests that's a requirement.)

Hope this helps...

--f

Replies are listed 'Best First'.
Re^2: Win32::Daemon service doesn't reach RUNNING state
by SwaJime (Scribe) on May 28, 2019 at 17:00 UTC

    Thank, I will look into this. Meanwhile, I found more info: Changing Callback_Start as follows allows it to run, however the resume/contine callback function does not work and does not benefit from a similar change:

    sub Callback_Start { my($Event, $Context) = @_; print $fh "Starting\n"; print $fh "DEBUG Setting Context\n"; $Context->{last_state} = SERVICE_RUNNING; print $fh "DEBUG Setting State\n"; Win32::Daemon::State( SERVICE_RUNNING ); print $fh "DEBUG Setting State again\n"; Win32::Daemon::State( SERVICE_RUNNING ); }

      The error message you mentioned was not triggered in my case. Thanks for the detail, and I will add that to my code. But that is not the issue directly at hand.

Re^2: Win32::Daemon service doesn't reach RUNNING state
by SwaJime (Scribe) on May 28, 2019 at 17:03 UTC

    Also, yes, I am running as admin.