in reply to win32::Daemon (stupid) questions

In the examples the functionality to "Create a Service" is in a different script but you could have that in the same script. You could put the install routine in a sub that only runs when a certian parameter is added eg --install. I have seen binary services written in C that implement things this way. IMHO the install routine simply adds the appropriate registry settings so the Service Control Manager can find the perl interpreter and give it the first parameter which is the full path of the perl script. The Service Control Manager is then responsible for starting, restarting and stopping your service.

AFAIK the "Not in timely fashion" error that you may see when getting the Service Control Manager to start the service is because the script did not notify the Service Control Manager of successful start up before a timeout.

--blm--

Replies are listed 'Best First'.
Re: Re: win32::Daemon (stupid) questions
by AcidHawk (Vicar) on Oct 16, 2002 at 08:01 UTC

    AFAIK the "Not in timely fashion" error that you may see when getting the Service Control Manager to start the service is because the script did not notify the Service Control Manager of successful start up before a timeout.

    I also see this when I have errors in my script. But of course I test them before I load them as a service..;) well not always... hence that error message.

    What I think you will need is the following

    } elsif( SERVICE_RUNNING == $State ) { # The service is running as normal... system('net send 127.0.0.1 Hello'); sleep 5; } else { # We have some unknown state... # reset it back to what we last knew the state to be... Win32::Daemon::State("$PrevState"); sleep( $timeout ); }

    -----
    Of all the things I've lost in my life, its my mind I miss the most.