Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Help converting to a Windows service

by beech (Parson)
on Mar 23, 2017 at 21:39 UTC ( [id://1185684]=note: print w/replies, xml ) Need Help??


in reply to Help converting to a Windows service

Can anyone explain to me how to use Win32::Daemon with this script to create a service from it? Right now it will run as a command line tool

Hi,

Follow the examples from the documentation?

Maybe Win32::Daemon::Simple is easier?

  • Comment on Re: Help converting to a Windows service

Replies are listed 'Best First'.
Re^2: Help converting to a Windows service
by bajangerry (Sexton) on Mar 23, 2017 at 22:03 UTC

    Ok, maybe I didn't explain myself correctly, I have been able to use the Win32::Daemon to create the service and it appears in the Services list as I would expect but it fails to run. I get an

    Error 1053: The service did not respond to the start or control request in a timely fashion

    I am not sure if this is due to the script I am using or if the actual Win::Daemon process is responsible.

    I did a test with a very simple script below and get the same error. I am not sure what I am doing wrong

    #! perl -slw use strict; use Win32; open LOG, '>', 'c:\Mitel\ACD\service.log' or die; select LOG; $|++; Win32::MsgBox( 'From test.pl at ' . localtime, 0, "test.pl" ); while( sleep 5 ) { Win32::MsgBox( 'From test.pl at ' . localtime, 0, "test.pl" ); print scalar localtime; } close LOG;

      Hi,

      What example are you following?

      Have you seen https://metacpan.org/pod/Win32%3A%3ADaemon#Example-1:-Simple-Service?

      It says

      This example service will delete all .tmp files from the c:\temp directory every time it starts. It will immediately terminate.
      use Win32::Daemon; # Tell the OS to start processing the service... Win32::Daemon::StartService(); # Wait until the service manager is ready for us to continue... while( SERVICE_START_PENDING != Win32::Daemon::State() ) { sleep( 1 ); } # Now let the service manager know that we are running... Win32::Daemon::State( SERVICE_RUNNING ); # Okay, go ahead and process stuff... unlink( glob( "c:\\temp\\*.tmp" ) ); # Tell the OS that the service is terminating... Win32::Daemon::StopService();

      Does that make sense ?

        I tried with that specific example as well and it also fails to run as a service so I am suspecting that there is something going on on my PC that may be preventing these from working so i am going to try with another one and see how it goes

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-16 16:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found